{"id":2261,"date":"2024-01-11T21:55:25","date_gmt":"2024-01-11T13:55:25","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=2261"},"modified":"2024-01-11T21:55:38","modified_gmt":"2024-01-11T13:55:38","slug":"windows-install-golang","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2024\/01\/11\/windows-install-golang\/","title":{"rendered":"Windows\u4e0b\u5b89\u88c5golang"},"content":{"rendered":"<p>\u5b98\u65b9\u4e0b\u8f7d\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/golang.google.cn\/dl\/\">https:\/\/golang.google.cn\/dl\/<\/a><br \/>\n\u63a8\u8350\u4e0b\u8f7d\uff1ago1.20.12<\/p>\n<pre><code># go version\ngo version go1.20.12 windows\/amd64\n\n# set GOPROXY=https:\/\/goproxy.cn<\/code><\/pre>\n<h2>IDEA\u914d\u7f6e<\/h2>\n<p>\u63d2\u4ef6\u5b89\u88c5\uff1a<code>Go<\/code><\/p>\n<p>IDEA GOPATH\u914d\u7f6e\uff1a<\/p>\n<p><code>Settings<\/code> -&gt; <code>Languages &amp; Frameworks<\/code> -&gt; <code>Go<\/code> -&gt; <code>GOPATH<\/code><\/p>\n<p>IDEA golang\u5f00\u542fmod\u540eimport\u62a5\u7ea2\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<p><code>Settings<\/code> -&gt; <code>Languages &amp; Frameworks<\/code> -&gt; <code>Go<\/code> -&gt; <code>Go Modules (vgo)<\/code> -&gt; \u52fe\u9009 <code>Enable Go Modules (vgo) integration<\/code><\/p>\n<h2>\u6d4b\u8bd5<\/h2>\n<pre><code class=\"language-go\"># vim json.go\n# go mod init appblog.cn\/go-test\/v2\ngo: creating new go.mod: module appblog.cn\/go-test\/v2\ngo: to add module requirements and sums:\n        go mod tidy\n\n# go install\n\n# go run json.go\n{\"nested\":{\"field\":\"value\"}}<\/code><\/pre>\n<pre><code class=\"language-go\">package main\n\nimport (\n    \"encoding\/json\"\n    \"fmt\"\n)\n\ntype InnerStruct struct {\n    Field string <code>json:&quot;field&quot;<\/code> \/\/ \u5185\u90e8JSON\u5bf9\u8c61\u7684\u5b57\u6bb5\u540d\u4e3a \"field\"\n}\n\ntype OuterStruct struct {\n    Nested InnerStruct <code>json:&quot;nested&quot;<\/code> \/\/ \u5916\u90e8JSON\u5bf9\u8c61\u7684\u5b57\u6bb5\u540d\u4e3a \"nested\"\n}\n\nfunc main() {\n    inner := InnerStruct{Field: \"value\"} \/\/ \u521d\u59cb\u5316\u5185\u90e8JSON\u5bf9\u8c61\n    outer := OuterStruct{}               \/\/ \u521d\u59cb\u5316\u5916\u90e8JSON\u5bf9\u8c61\n\n    \/\/ \u5c06\u5185\u90e8JSON\u5bf9\u8c61\u8d4b\u503c\u7ed9\u5916\u90e8JSON\u5bf9\u8c61\u7684\u5b57\u6bb5\n    outer.Nested = inner\n\n    \/\/ \u5c06\u5916\u90e8JSON\u5bf9\u8c61\u8f6c\u6362\u6210JSON\u683c\u5f0f\u7684\u5b57\u7b26\u4e32\n    result, err := json.Marshal(outer)\n    if err != nil {\n        panic(err)\n    }\n\n    fmt.Println(string(result))\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5b98\u65b9\u4e0b\u8f7d\uff1ahttps:\/\/golang.google.cn\/dl\/ \u63a8\u8350\u4e0b\u8f7d\uff1ago1.20.12 # go v [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[573],"tags":[137],"class_list":["post-2261","post","type-post","status-publish","format-standard","hentry","category-golang","tag-go"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=2261"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2261\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=2261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=2261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=2261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}