修改连接错误,修正一些报引用错误 (#1655)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
修复了全角括号导致超链接不能正常访问的错误。 修复了一些URL中的"/"被改成" / "的错误。 修复了一些包引用中"/"被改成" / "的错误。 修复有超链接被翻译成中文的错误。
authored by 尹宝强 · committed by thinkerou · parent 6053156 · Browse files · 1 file·+34 added−34 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+34 added−34 removed
- other:+34 added−34 removed
Provenance
- Commit
1f576fb- Tree
7dc9c5d- Author
尹宝强 <wmdandme@gmail.com>- Committer
thinkerou <thinkerou@gmail.com>- Parent
6053156
1 file changed+34 added−34 removed
modified:README_ZH.md+34 added-34 removed
77 unmodified lines78 ```go79 import "github.com/gin-gonic/gin"80 ```81 82-3. (可选)如果使用诸如`http.StatusOK`之类的常量,则需要引入 `net / http` 包。82+3. (可选)如果使用诸如`http.StatusOK`之类的常量,则需要引入 `net/http` 包。83 84 ```go85 import "net/http"86 ```112 unmodified lines199 - [x] API冻结,新版本不会破坏您的代码。200 201 ## 使用 [jsoniter](https://github.com/json-iterator/go) 构建202 203-Gin使用`encoding / json`作为默认的json包,但您可以通过其他标签的构建更改为[jsoniter](https://github.com/json-iterator/go)。203+Gin使用`encoding/json`作为默认的json包,但您可以通过其他标签的构建更改为[jsoniter](https://github.com/json-iterator/go)。204 205 ```sh206 $ go build -tags=jsoniter .207 ```150 unmodified lines358 ### 上传文件359 360 #### 单个文件上传361 362-参考问题[#774](https://github.com/gin-gonic/gin/issues/774)和详细[示例代码](examples / upload-file / single)。362+参考问题[#774](https://github.com/gin-gonic/gin/issues/774)和详细[示例代码](examples/upload-file/single)。363 364 ```go365 func main() {366 router := gin.Default()22 unmodified lines389 ```390 391 #### 多文件上传392 393-查看详细信息[示例代码](examples / upload-file / multiple)。393+查看详细信息[示例代码](examples/upload-file/multiple)。394 395 ```go396 func main() {397 router := gin.Default()131 unmodified lines529 ### 模型绑定和验证530 531 要将请求主体绑定到类型中,请使用模型绑定。我们目前支持JSON,XML和标准表单值的绑定(foo = bar&boo = baz)。532 533-Gin使用[** go-playground / validator.v8 **](https://github.com/go-playground/validator)进行验证。检查有关标签用法的完整文档[此处](http://godoc.org/gopkg.in/go-playground/validator.v8#hdr-Baked_In_Validators_and_Tags)。533+Gin使用[** go-playground/validator.v8 **](https://github.com/go-playground/validator)进行验证。检查有关标签用法的完整文档[此处](http://godoc.org/gopkg.in/go-playground/validator.v8#hdr-Baked_In_Validators_and_Tags)。534 535 请注意,您需要在要绑定的所有字段上设置相应的绑定标记。例如,从JSON绑定时,设置`json:“fieldname”`。536 537 此外,Gin提供了两组绑定方法:538 - **类型** - 必须绑定539 - **方法** - `Bind`,`BindJSON`,`BindXML`,`BindQuery`540- - **行为** - 这些方法在引擎盖下使用`MustBindWith`。如果存在绑定错误,则使用`c.AbortWithError(400,err).SetType(ErrorTypeBind)`中止请求。这将响应状态代码设置为400,并将`Content-Type`标头设置为`text / plain;字符集= UTF-8`。请注意,如果您在此之后尝试设置响应代码,则会发出警告“[GIN-debug] [警告]标题已经写入。想用422`覆盖状态代码400。如果您希望更好地控制行为,请考虑使用`ShouldBind`等效方法。540+ - **行为** - 这些方法在引擎盖下使用`MustBindWith`。如果存在绑定错误,则使用`c.AbortWithError(400,err).SetType(ErrorTypeBind)`中止请求。这将响应状态代码设置为400,并将`Content-Type`标头设置为`text/plain;字符集= UTF-8`。请注意,如果您在此之后尝试设置响应代码,则会发出警告“[GIN-debug] [警告]标题已经写入。想用422`覆盖状态代码400。如果您希望更好地控制行为,请考虑使用`ShouldBind`等效方法。541 - **类型** - 应该绑定542 - **方法** - `ShouldBind`,`ShouldBindJSON`,`ShouldBindXML`,`ShouldBindQuery`543 - **行为** - 这些方法在引擎盖下使用`ShouldBindWith`。如果存在绑定错误,则返回错误,开发人员有责任正确处理请求和错误。544 97 unmodified lines642 使用上面 的`curl` 命令运行上面的例子时,它返回错误。 因为这个例子使用 `binding:'需要``````。 如果使用 `binding:“ - ``````,那么在再次运行上面的例子时它不会返回错误。643 644 ### 自定义验证器645 646-也可以注册自定义验证器。 请参阅[示例代码](examples / custom-validation / server.go)。646+也可以注册自定义验证器。 请参阅[示例代码](examples/custom-validation/server.go)。647 648-[embedmd]:#(examples / custom-validation / server.go go)648+[embedmd]:#(examples/custom-validation/server.go go)649 ```go650 package main651 652 import (53 unmodified lines706 $ curl "localhost:8085/bookable?check_in=2018-03-08&check_out=2018-03-09"707 {"error":"Key: 'Booking.CheckIn' Error:Field validation for 'CheckIn' failed on the 'bookabledate' tag"}708 ```709 710-[结构级验证](https://github.com/go-playground/validator/releases/tag/v8.7)也可以这种方式注册。711-请参阅[struct-lvl-validation示例](examples / struct-lvl-validations)以了解更多信息。710+[结构级验证](https://github.com/go-playground/validator/releases/tag/v8.7)也可以这种方式注册。711+请参阅[struct-lvl-validation示例](examples/struct-lvl-validations)以了解更多信息。712 713 ### 只绑定查询字符串714 715-`ShouldBindQuery` 函数只绑定查询参数而不是后期数据。 请参阅[详细信息](https://github.com/gin-gonic/gin/issues/742#issuecomment-315953017)。715+`ShouldBindQuery` 函数只绑定查询参数而不是后期数据。 请参阅[详细信息](https://github.com/gin-gonic/gin/issues/742#issuecomment-315953017)。716 717 ```go718 package main719 27 unmodified lines747 ```748 749 ### 绑定查询字符串或发布数据750 751-请参阅[详细信息](https://github.com/gin-gonic/gin/issues/742#issuecomment-264681292)。751+请参阅[详细信息](https://github.com/gin-gonic/gin/issues/742#issuecomment-264681292)。752 753 ```go754 package main755 37 unmodified lines793 ```794 795 ### 绑定 HTML 复选框796 797-参见[详细信息](https://github.com/gin-gonic/gin/issues/129#issuecomment-124260092)797+参见[详细信息](https://github.com/gin-gonic/gin/issues/129#issuecomment-124260092)798 799 main.go800 801 ```go128 unmodified lines930 ```931 932 #### SecureJSON933 934-使用 SecureJSON 来防止 json 劫持。 如果给定的结构是数组值,则默认预 置`“while(1),”` 到响应体。934+使用 SecureJSON 来防止 json 劫持。 如果给定的结构是数组值,则默认预 置`“while(1),”` 到响应体。935 936 ```go937 func main() {938 r := gin.Default()127 unmodified lines1066 ```1067 1068 ### HTML 渲染1069 1070-使用LoadHTMLGlob()或LoadHTMLFiles()1070+使用LoadHTMLGlob()或LoadHTMLFiles()1071 1072 ```go1073 func main() {1074 router := gin.Default()83 unmodified lines1158 1159 ```go1160 r := gin.Default()1161 r.Delims("{[{", "}]}")1162- r.LoadHTMLGlob("/path/to/templates"))1162+ r.LoadHTMLGlob("/path/to/templates")1163 ```1164 1165 #### 自定义模板功能1166 1167-查看详细信息[示例代码](示例/模板)。1167+查看详细信息[示例代码](examples/template)。1168 1169 main.go1170 1171 ```go42 unmodified lines1214 ```1215 1216 ### 多模板1217 1218-Gin 允许默认只使用一个 html 模板。 检查[多模板渲染](https://github.com/gin-contrib/multitemplate)以使用 go 1.6 `block template` 等功能。1218+Gin 允许默认只使用一个 html 模板。 检查[多模板渲染](https://github.com/gin-contrib/multitemplate)以使用 go 1.6 `block template` 等功能。1219 1220 ### 重定向1221 1222 Issuing a HTTP redirect is easy. Both internal and external locations are supported.131 unmodified lines1354 ```1355 1356 ### 自定义 HTTP 配置1357 1358-直接使用`http.ListenAndServe()`,如下所示:1358+直接使用`http.ListenAndServe()`,如下所示:1359 1360 ```go1361 func main() {1362 router := gin.Default()77 unmodified lines1440 ```1441 1442 ### 使用 Gin 运行多个服务1443 1444-请参阅[问题](https://github.com/gin-gonic/gin/issues/346)并尝试以下示例:1444+请参阅[问题](https://github.com/gin-gonic/gin/issues/346)并尝试以下示例:1445 1446 [embedmd]:# (examples/multiple-service/main.go go)1447 ```go1448 package main76 unmodified lines1525 1526 您想要优雅地重启或停止您的Web服务器吗?1527 有一些方法可以做到这一点。1528 1529-我们可以使用[fvbock / endless](https://github.com/fvbock/endless)来替换默认的`ListenAndServe`。 有关更多详细信息,请参阅问题[#296](https://github.com/gin-gonic/gin/issues/296)。1529+我们可以使用[fvbock/endless](https://github.com/fvbock/endless)来替换默认的`ListenAndServe`。 有关更多详细信息,请参阅问题[#296](https://github.com/gin-gonic/gin/issues/296)。1530 1531 ```go1532 router := gin.Default()1533 router.GET("/", handler)2 unmodified lines1536 ```1537 1538 另一种替代方案:1539 1540-* [manners](https://github.com/braintree/manners):礼貌的Go HTTP服务器,可以正常关闭。1541-* [graceful](https://github.com/tylerb/graceful):Graceful是一个Go包,可以正常关闭http.Handler服务器。1542-* [grace](https://github.com/facebookgo/grace):Go服务器的平滑重启和零停机时间部署。1540+* [manners](https://github.com/braintree/manners):礼貌的Go HTTP服务器,可以正常关闭。1541+* [graceful](https://github.com/tylerb/graceful):Graceful是一个Go包,可以正常关闭http.Handler服务器。1542+* [grace](https://github.com/facebookgo/grace):Go服务器的平滑重启和零停机时间部署。1543 1544-如果您使用的是Go 1.8,则可能不需要使用此库! 考虑使用http.Server的内置[Shutdown()](https://golang.org/pkg/net/http/#Server.Shutdown)方法进行正常关机。 请参阅gin的完整[graceful-shutdown](./ examples / graceful-shutdown)示例。1544+如果您使用的是Go 1.8,则可能不需要使用此库! 考虑使用http.Server的内置[Shutdown()](https://golang.org/pkg/net/http/#Server.Shutdown)方法进行正常关机。 请参阅gin的完整[graceful-shutdown](./examples /graceful-shutdown)示例。1545 1546 [embedmd]:# (examples/graceful-shutdown/graceful-shutdown/server.go go)1547 ```go1548 // +build go1.887 unmodified lines1636 return t, nil1637 }1638 ```1639 1640-请参阅`examples / assets-in-binary`目录中的完整示例。1640+请参阅`examples/assets-in-binary`目录中的完整示例。1641 1642 ### Bind form-data request with custom struct1643 1644 以下示例使用自定义结构:142 unmodified lines1787 对性能有轻微影响,所以如果你这样做,你不应该使用这种方法1788 足以立刻调用绑定。1789 *只有某些格式需要此功能 - “JSON”,“XML”,“MsgPack”,1790 `ProtoBuf`。 对于其他格式,`Query`,`Form`,`FormPost`,`FormMultipart`,1791-可以被`c.ShouldBind()`多次调用而不会造成任何损害1792-表现(见[#1341](https://github.com/gin-gonic/gin/pull/1341))。1791+可以被`c.ShouldBind()`多次调用而不会造成任何损害1792+表现(见[#1341](https://github.com/gin-gonic/gin/pull/1341)。1793 1794 ### http2 server 推送1795 1796 1797-http.Pusher仅支持** go1.8 + **。 有关详细信息,请参阅[golang blog](https://blog.golang.org/h2push)。1797+http.Pusher仅支持** go1.8 + **。 有关详细信息,请参阅[golang blog](https://blog.golang.org/h2push)。1798 1799 [embedmd]:# (examples/http-pusher/main.go go)1800 ```go1801 package main83 unmodified lines1885 1886 1887 ## 测试1888 1889-`net / http / httptest`包是HTTP测试的首选方式。1889+`net/http/httptest`包是HTTP测试的首选方式。1890 1891 ```go1892 package main1893 38 unmodified lines1932 1933 ## 用户1934 1935 1936-使用[Gin](https://github.com/gin-gonic/gin)Web框架的令人敬畏的项目列表。1936+使用[Gin](https://github.com/gin-gonic/gin)Web框架的令人尊敬的项目列表。1937 1938-* [drone](https://github.com/drone/drone):drone,用Go编写。1939-* [gorush](https://github.com/appleboy/gorush):用Go编写的推送通知服务器。1940-* [fnproject](https://github.com/fnproject/fn):容器本机,云无关的无服务器平台。1938+* [drone](https://github.com/drone/drone):drone,用Go编写。1939+* [gorush](https://github.com/appleboy/gorush):用Go编写的推送通知服务器。1940+* [fnproject](https://github.com/fnproject/fn):容器本机,云无关的无服务器平台。