{"id":21672,"date":"2024-11-19T08:43:24","date_gmt":"2024-11-19T00:43:24","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21672\/"},"modified":"2024-11-19T08:43:24","modified_gmt":"2024-11-19T00:43:24","slug":"vscode%e4%b8%8a%e6%90%ad%e5%bb%bago%e5%bc%80%e5%8f%91%e7%8e%af%e5%a2%83%e8%af%a6%e7%bb%86%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21672\/","title":{"rendered":"vscode\u4e0a\u642d\u5efago\u5f00\u53d1\u73af\u5883\u8be6\u7ec6\u6559\u7a0b"},"content":{"rendered":"<blockquote><p>\n  \u642d\u5efa go \u5f00\u53d1\u73af\u5883\u5305\u62ec\uff1a\u5b89\u88c5 go \u8bed\u8a00\u5e76\u8bbe\u7f6e path \u73af\u5883\u53d8\u91cf\u3002\u5b89\u88c5 visual studio code (vscode)\u3002\u5b89\u88c5 &#8220;go&#8221; \u6269\u5c55\u3002\u914d\u7f6e vscode \u4e2d\u7684 go \u8bbe\u7f6e\u548c gopath\u3002\u521b\u5efa go \u9879\u76ee\u5e76\u7f16\u5199 go \u4ee3\u7801\u3002\u4f7f\u7528 f5 \u8fd0\u884c go \u7a0b\u5e8f\u3002\u5229\u7528 intellisense \u4ee3\u7801\u81ea\u52a8\u5b8c\u6210\u548c\u8c03\u8bd5\u529f\u80fd\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202407\/05\/2024070520460765219.jpg\" class=\"aligncenter\" title=\"vscode\u4e0a\u642d\u5efago\u5f00\u53d1\u73af\u5883\u8be6\u7ec6\u6559\u7a0b\u63d2\u56fe\" alt=\"vscode\u4e0a\u642d\u5efago\u5f00\u53d1\u73af\u5883\u8be6\u7ec6\u6559\u7a0b\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5728 VSCode \u4e0a\u642d\u5efa Go \u5f00\u53d1\u73af\u5883<\/strong><\/p>\n<p><strong>\u8bbe\u7f6e Go \u8bed\u8a00\u73af\u5883<\/strong><\/p>\n<ol>\n<li> <strong>\u5b89\u88c5 Go \u8bed\u8a00\uff1a<\/strong>\u4ece\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5 Go \u8bed\u8a00\uff0c\u786e\u4fdd\u5df2\u5c06 Go bin \u8def\u5f84\u6dfb\u52a0\u5230\u7cfb\u7edf PATH \u73af\u5883\u53d8\u91cf\u4e2d\u3002<\/li>\n<li> <strong>\u9a8c\u8bc1 Go \u5b89\u88c5\uff1a<\/strong>\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165 go version \u547d\u4ee4\uff0c\u5982\u679c\u6b63\u786e\u5b89\u88c5\uff0c\u5c06\u663e\u793a Go \u7248\u672c\u4fe1\u606f\u3002<\/li>\n<\/ol>\n<p><strong>\u5b89\u88c5 Visual Studio Code<\/strong><\/p>\n<ol>\n<li>\u4ece\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5 Visual Studio Code (VSCode)\u3002<\/li>\n<li>\u5b89\u88c5 Go \u6269\u5c55\uff1a\u5728 VSCode \u4e2d\uff0c\u6253\u5f00\u6269\u5c55\u9762\u677f\u5e76\u641c\u7d22 &#8220;Go&#8221; \u6269\u5c55\u3002\u5b89\u88c5 &#8220;Go&#8221; \u6269\u5c55\u3002<\/li>\n<\/ol>\n<p><strong>\u914d\u7f6e VSCode<\/strong><\/p>\n<ol>\n<li> <strong>\u542f\u7528 Go\uff1a<\/strong>\u5728 VSCode \u4e2d\uff0c\u6253\u5f00 &#8220;\u8bbe\u7f6e&#8221;\uff08Ctrl + , \u6216 Cmd + ,\uff09\uff0c\u627e\u5230 &#8220;Go: Go to Tool&#8221; \u8bbe\u7f6e\uff0c\u5e76\u786e\u4fdd\u5df2\u5c06\u5176\u8bbe\u7f6e\u4e3a &#8220;\u9ed8\u8ba4 Go 1.x&#8221;\u3002<\/li>\n<li> <strong>\u914d\u7f6e GOPATH\uff1a<\/strong>\u8bbe\u7f6e &#8220;GOPATH&#8221; \u73af\u5883\u53d8\u91cf\uff0c\u6307\u5411\u60a8\u7684 Go \u9879\u76ee\u7684\u5de5\u4f5c\u533a\u3002GOPATH \u662f Go \u9879\u76ee\u7684\u6839\u76ee\u5f55\uff0c\u5176\u4e2d\u5305\u542b &#8220;src&#8221;\u3001&#8221;bin&#8221; \u548c &#8220;pkg&#8221; \u5b50\u76ee\u5f55\u3002<\/li>\n<\/ol>\n<p><strong>\u521b\u5efa Go \u9879\u76ee<\/strong><\/p>\n<ol>\n<li>\u5728\u60a8\u7684\u5de5\u4f5c\u533a\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6587\u4ef6\u5939\uff0c\u4f8b\u5982 &#8220;my-go-project&#8221;\u3002<\/li>\n<li>\u5728\u6587\u4ef6\u5939\u4e2d\uff0c\u521b\u5efa &#8220;src&#8221; \u5b50\u76ee\u5f55\u3002<\/li>\n<li>\u5728 &#8220;src&#8221; \u5b50\u76ee\u5f55\u4e2d\uff0c\u521b\u5efa &#8220;main.go&#8221; \u6587\u4ef6\u3002<\/li>\n<\/ol>\n<p><strong>\u7f16\u5199 Go \u4ee3\u7801<\/strong><\/p>\n<p>\u5728 &#8220;main.go&#8221; \u6587\u4ef6\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre>package main\n\nimport \"fmt\"\n\nfunc main() {\n  fmt.Println(\"Hello, world!\")\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u8fd0\u884c Go \u7a0b\u5e8f<\/strong><\/p>\n<ol>\n<li>\u5728 VSCode \u4e2d\uff0c\u6309 F5 \u6216\u5355\u51fb\u8c03\u8bd5\u5de5\u5177\u680f\u4e0a\u7684 &#8220;\u8fd0\u884c&#8221; \u6309\u94ae\u3002<\/li>\n<li>VSCode \u5c06\u6784\u5efa\u5e76\u8fd0\u884c\u60a8\u7684 Go \u7a0b\u5e8f\u3002<\/li>\n<li>\u8f93\u51fa\u5c06\u663e\u793a\u5728\u7ec8\u7aef\u6216\u8c03\u8bd5\u63a7\u5236\u53f0\u4e2d\u3002<\/li>\n<\/ol>\n<p><strong>\u4f7f\u7528 IntelliSense<\/strong><\/p>\n<p>VSCode \u7684 Go \u6269\u5c55\u63d0\u4f9b\u4e86 IntelliSense \u529f\u80fd\uff0c\u53ef\u5e2e\u52a9\u60a8\u81ea\u52a8\u5b8c\u6210\u4ee3\u7801\u5e76\u63d0\u4f9b\u8bed\u6cd5\u63d0\u793a\u3002\u786e\u4fdd\u5df2\u542f\u7528 IntelliSense\uff08&#8221;\u8bbe\u7f6e&#8221; &gt; &#8220;Go: IntelliSense&#8221;\uff09\u3002<\/p>\n<p><strong>\u8c03\u8bd5 Go \u7a0b\u5e8f<\/strong><\/p>\n<ol>\n<li>\u8bbe\u7f6e\u65ad\u70b9\uff1a\u5728\u4ee3\u7801\u4e2d\u5355\u51fb\u884c\u53f7\u65c1\u8fb9\u7684\u5de6\u8fb9\u7f18\uff0c\u4ee5\u8bbe\u7f6e\u65ad\u70b9\u3002<\/li>\n<li>\u5f00\u59cb\u8c03\u8bd5\uff1a\u6309 F5 \u6216\u5355\u51fb\u8c03\u8bd5\u5de5\u5177\u680f\u4e0a\u7684 &#8220;\u8c03\u8bd5&#8221; \u6309\u94ae\u3002<\/li>\n<li>VSCode \u5c06\u5728\u65ad\u70b9\u5904\u6682\u505c\u7a0b\u5e8f\u6267\u884c\uff0c\u5141\u8bb8\u60a8\u68c0\u67e5\u53d8\u91cf\u548c\u6b65\u9aa4\u6267\u884c\u4ee3\u7801\u3002<\/li>\n<\/ol>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4e0a\u642d\u5efago\u5f00\u53d1\u73af\u5883\u8be6\u7ec6\u6559\u7a0b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u642d\u5efa go \u5f00\u53d1\u73af\u5883\u5305\u62ec\uff1a\u5b89\u88c5 go \u8bed\u8a00\u5e76\u8bbe\u7f6e path \u73af\u5883\u53d8\u91cf\u3002\u5b89\u88c5 visual studio code (vscode)\u3002\u5b89\u88c5 &#8220;go&#8221; \u6269\u5c55\u3002\u914d\u7f6e vscode \u4e2d\u7684 go \u8bbe\u7f6e\u548c gopath\u3002\u521b\u5efa go \u9879\u76ee\u5e76\u7f16\u5199 go \u4ee3\u7801\u3002\u4f7f\u7528 f5 \u8fd0\u884c go \u7a0b\u5e8f\u3002\u5229\u7528 intellisense \u4ee3\u7801\u81ea\u52a8\u5b8c\u6210\u548c\u8c03\u8bd5\u529f\u80fd\u3002 \u5728 VSCode \u4e0a\u642d\u5efa Go \u5f00\u53d1\u73af\u5883 \u8bbe\u7f6e Go \u8bed\u8a00\u73af\u5883 \u5b89\u88c5 Go \u8bed\u8a00\uff1a\u4ece\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5 Go \u8bed\u8a00\uff0c\u786e\u4fdd\u5df2\u5c06 Go bin \u8def\u5f84\u6dfb\u52a0\u5230\u7cfb\u7edf PATH \u73af\u5883\u53d8\u91cf\u4e2d\u3002 \u9a8c\u8bc1 Go \u5b89\u88c5\uff1a\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165 go version \u547d\u4ee4\uff0c\u5982\u679c\u6b63\u786e\u5b89\u88c5\uff0c\u5c06\u663e\u793a Go \u7248\u672c\u4fe1\u606f\u3002 \u5b89\u88c5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-21672","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21672","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=21672"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21672\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}