{"id":151,"date":"2024-02-09T00:12:51","date_gmt":"2024-02-08T16:12:51","guid":{"rendered":"https:\/\/669082.xyz\/?p=151"},"modified":"2024-02-24T16:22:08","modified_gmt":"2024-02-24T08:22:08","slug":"202408%e5%ad%a6%e4%b9%a0golang-gin%e6%a1%86%e6%9e%b6","status":"publish","type":"post","link":"https:\/\/669082.xyz\/index.php\/2024\/02\/09\/202408%e5%ad%a6%e4%b9%a0golang-gin%e6%a1%86%e6%9e%b6\/","title":{"rendered":"20240208\u5b66\u4e60Golang gin\u6846\u67b6"},"content":{"rendered":"<p>gin\u6846\u67b6\u521d\u4f53\u9a8c<\/p>\n<pre><code class=\"language-shell\">go get -u github.com\/gin-gonic\/gin<\/code><\/pre>\n<pre><code class=\"language-go\">package main\n\nimport (\n  &quot;net\/http&quot;\n\n  &quot;github.com\/gin-gonic\/gin&quot;\n)\n\nfunc main() {\n  r := gin.Default()\n  r.GET(&quot;\/ping&quot;, func(c *gin.Context) {\n    c.JSON(http.StatusOK, gin.H{\n      &quot;message&quot;: &quot;pong&quot;,\n    })\n  })\n  r.Run() \/\/ listen and serve on 0.0.0.0:8080 (for windows &quot;localhost:8080&quot;)\n}<\/code><\/pre>\n<p>gin\u8def\u7531\u5206\u7ec4<\/p>\n<pre><code class=\"language-go\">func main() {\n    r := gin.Default()\n\n    \/\/\u8def\u7531\u5206\u7ec4\n    user := r.Group(&quot;\/user&quot;)\n    {\n        user.GET(&quot;\/hello&quot;, func(c *gin.Context) {\n            c.String(http.StatusOK, &quot;world&quot;)\n        })\n    }\n\n    r.Run(&quot;:8888&quot;) \/\/ listen and serve on 0.0.0.0:8080 (for windows &quot;localhost:8080&quot;)\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>gin\u6846\u67b6\u521d\u4f53\u9a8c go get -u github.com\/gin-gonic\/gin packag [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-151","post","type-post","status-publish","format-standard","hentry","category-golang"],"_links":{"self":[{"href":"https:\/\/669082.xyz\/index.php\/wp-json\/wp\/v2\/posts\/151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/669082.xyz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/669082.xyz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/669082.xyz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/669082.xyz\/index.php\/wp-json\/wp\/v2\/comments?post=151"}],"version-history":[{"count":3,"href":"https:\/\/669082.xyz\/index.php\/wp-json\/wp\/v2\/posts\/151\/revisions"}],"predecessor-version":[{"id":170,"href":"https:\/\/669082.xyz\/index.php\/wp-json\/wp\/v2\/posts\/151\/revisions\/170"}],"wp:attachment":[{"href":"https:\/\/669082.xyz\/index.php\/wp-json\/wp\/v2\/media?parent=151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/669082.xyz\/index.php\/wp-json\/wp\/v2\/categories?post=151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/669082.xyz\/index.php\/wp-json\/wp\/v2\/tags?post=151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}