Files

1 line
34 KiB
JavaScript

"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6052],{3035:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/install03-94003cedd4c8c3d4123d5d1f32165b7a.png"},17141:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_shell3-6ff42e26ac39aa9d37ef684ee2df98d9.png"},19177:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/install01-d64ed61472ba87440aff0c0ea625f68a.png"},28453:(e,n,d)=>{d.d(n,{R:()=>c,x:()=>o});var s=d(96540);const l={},i=s.createContext(l);function c(e){const n=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:c(e.components),s.createElement(i.Provider,{value:n},e.children)}},39172:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/install04-175fa35fec313fe8a0e68a98285967e9.png"},48021:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode1-19b2bf87bcff59147b3c3e80150a19cf.gif"},52055:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/mac_install_go-78ef9274462840922eb6c8b9be929cb8.png"},61145:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_plugin-1666acd91203e8faed047f528bbca30a.png"},64876:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_shell2-209f754c65d23b1bfdcd6bb593412e1c.png"},69619:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/download2-5037dead2e7bfecc169e95cc9449fc44.png"},74008:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/download1-fd264457dd6ba747b5c8c48e7b2479b1.png"},77018:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_shell4-a13979f63666d799df0b3e9ece572b36.png"},79094:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/install06-9eae44f8976c87e4bddd142b1937fcf9.png"},83879:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_shell1-d92eb0e53eada281e2ef0a8e5054768f.png"},88210:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/install02-fb3f463fadd80bb5a1b075b7eff9478b.png"},89705:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_menu-ded71d067fd55419bd69c091f0ef9929.png"},91581:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_home-457928958889c5d715996ec4d55aa2f2.png"},92017:(e,n,d)=>{d.r(n),d.d(n,{assets:()=>h,contentTitle:()=>o,default:()=>x,frontMatter:()=>c,metadata:()=>s,toc:()=>r});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e","title":"\u5b89\u88c5Go\u8bed\u8a00\u53ca\u642d\u5efaGo\u8bed\u8a00\u5f00\u53d1\u73af\u5883","description":"\u6ce8\u610f\uff1aGo\u8bed\u8a001.14\u7248\u672c\u4e4b\u540e\u63a8\u8350\u4f7f\u7528go modules\u7ba1\u7406\u4f9d\u8d56\uff0c\u4e5f\u4e0d\u518d\u9700\u8981\u628a\u4ee3\u7801\u5199\u5728GOPATH\u76ee\u5f55\u4e0b\u4e86\uff0c\u4e4b\u524d\u65e7\u7248\u672c\u7684\u6559\u7a0b\u6233\u8fd9\u4e2a\u94fe\u63a5\u3002","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/01.GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/01.GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u57fa\u7840\u7f16\u7a0b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53d8\u91cf\u548c\u5e38\u91cf","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf"}}');var l=d(74848),i=d(28453);const c={},o="\u5b89\u88c5Go\u8bed\u8a00\u53ca\u642d\u5efaGo\u8bed\u8a00\u5f00\u53d1\u73af\u5883",h={},r=[{value:"\u4e0b\u8f7d",id:"\u4e0b\u8f7d",level:2},{value:"\u4e0b\u8f7d\u5730\u5740",id:"\u4e0b\u8f7d\u5730\u5740",level:3},{value:"\u7248\u672c\u7684\u9009\u62e9",id:"\u7248\u672c\u7684\u9009\u62e9",level:3},{value:"\u5b89\u88c5",id:"\u5b89\u88c5",level:2},{value:"Windows\u5b89\u88c5",id:"windows\u5b89\u88c5",level:3},{value:"Linux\u4e0b\u5b89\u88c5",id:"linux\u4e0b\u5b89\u88c5",level:3},{value:"Mac\u4e0b\u5b89\u88c5",id:"mac\u4e0b\u5b89\u88c5",level:3},{value:"\u68c0\u67e5",id:"\u68c0\u67e5",level:3},{value:"GOROOT\u548cGOPATH",id:"goroot\u548cgopath",level:2},{value:"GOPROXY \u975e\u5e38\u91cd\u8981",id:"goproxy-\u975e\u5e38\u91cd\u8981",level:3},{value:"Go\u5f00\u53d1\u7f16\u8f91\u5668",id:"go\u5f00\u53d1\u7f16\u8f91\u5668",level:2},{value:"VS Code\u4ecb\u7ecd",id:"vs-code\u4ecb\u7ecd",level:3},{value:"\u4e0b\u8f7d\u4e0e\u5b89\u88c5",id:"\u4e0b\u8f7d\u4e0e\u5b89\u88c5",level:3},{value:"\u914d\u7f6e",id:"\u914d\u7f6e",level:3},{value:"\u5b89\u88c5\u4e2d\u6587\u7b80\u4f53\u63d2\u4ef6",id:"\u5b89\u88c5\u4e2d\u6587\u7b80\u4f53\u63d2\u4ef6",level:4},{value:"\u5b89\u88c5go\u6269\u5c55",id:"\u5b89\u88c5go\u6269\u5c55",level:4},{value:"\u7b2c\u4e00\u4e2aGo\u7a0b\u5e8f",id:"\u7b2c\u4e00\u4e2ago\u7a0b\u5e8f",level:2},{value:"Hello World",id:"hello-world",level:3},{value:"go mod init",id:"go-mod-init",level:4},{value:"\u7f16\u5199\u4ee3\u7801",id:"\u7f16\u5199\u4ee3\u7801",level:4},{value:"\u7f16\u8bd1",id:"\u7f16\u8bd1",level:3},{value:"Windows\u4e0bVSCode\u5207\u6362cmd.exe\u4f5c\u4e3a\u9ed8\u8ba4\u7ec8\u7aef",id:"windows\u4e0bvscode\u5207\u6362cmdexe\u4f5c\u4e3a\u9ed8\u8ba4\u7ec8\u7aef",level:3},{value:"go run",id:"go-run",level:3},{value:"go install",id:"go-install",level:3},{value:"\u8de8\u5e73\u53f0\u7f16\u8bd1",id:"\u8de8\u5e73\u53f0\u7f16\u8bd1",level:3},{value:"Windows\u7f16\u8bd1Linux\u53ef\u6267\u884c\u6587\u4ef6",id:"windows\u7f16\u8bd1linux\u53ef\u6267\u884c\u6587\u4ef6",level:4},{value:"Windows\u7f16\u8bd1Mac\u53ef\u6267\u884c\u6587\u4ef6",id:"windows\u7f16\u8bd1mac\u53ef\u6267\u884c\u6587\u4ef6",level:4},{value:"Mac\u7f16\u8bd1Linux\u53ef\u6267\u884c\u6587\u4ef6",id:"mac\u7f16\u8bd1linux\u53ef\u6267\u884c\u6587\u4ef6",level:4},{value:"Mac\u7f16\u8bd1Windows\u53ef\u6267\u884c\u6587\u4ef6",id:"mac\u7f16\u8bd1windows\u53ef\u6267\u884c\u6587\u4ef6",level:4},{value:"Linux\u7f16\u8bd1Mac\u53ef\u6267\u884c\u6587\u4ef6",id:"linux\u7f16\u8bd1mac\u53ef\u6267\u884c\u6587\u4ef6",level:4},{value:"Linux\u7f16\u8bd1Windows\u53ef\u6267\u884c\u6587\u4ef6",id:"linux\u7f16\u8bd1windows\u53ef\u6267\u884c\u6587\u4ef6",level:4}];function a(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",p:"p",pre:"pre",strong:"strong",...(0,i.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"\u5b89\u88c5go\u8bed\u8a00\u53ca\u642d\u5efago\u8bed\u8a00\u5f00\u53d1\u73af\u5883",children:"\u5b89\u88c5Go\u8bed\u8a00\u53ca\u642d\u5efaGo\u8bed\u8a00\u5f00\u53d1\u73af\u5883"})}),"\n",(0,l.jsxs)(n.p,{children:["**\u6ce8\u610f\uff1a**Go\u8bed\u8a001.14\u7248\u672c\u4e4b\u540e\u63a8\u8350\u4f7f\u7528go modules\u7ba1\u7406\u4f9d\u8d56\uff0c\u4e5f\u4e0d\u518d\u9700\u8981\u628a\u4ee3\u7801\u5199\u5728GOPATH\u76ee\u5f55\u4e0b\u4e86\uff0c\u4e4b\u524d\u65e7\u7248\u672c\u7684\u6559\u7a0b\u6233\u8fd9\u4e2a",(0,l.jsx)(n.a,{href:"https://www.liwenzhou.com/posts/Go/install_go_dev_old/",children:"\u94fe\u63a5"}),"\u3002"]}),"\n",(0,l.jsx)(n.h2,{id:"\u4e0b\u8f7d",children:"\u4e0b\u8f7d"}),"\n",(0,l.jsx)(n.h3,{id:"\u4e0b\u8f7d\u5730\u5740",children:"\u4e0b\u8f7d\u5730\u5740"}),"\n",(0,l.jsxs)(n.p,{children:["Go\u5b98\u7f51\u4e0b\u8f7d\u5730\u5740\uff1a",(0,l.jsx)(n.a,{href:"https://golang.org/dl/",children:"https://golang.org/dl/"})]}),"\n",(0,l.jsxs)(n.p,{children:["Go\u5b98\u65b9\u955c\u50cf\u7ad9\uff08\u63a8\u8350\uff09\uff1a",(0,l.jsx)(n.a,{href:"https://golang.google.cn/dl/",children:"https://golang.google.cn/dl/"})]}),"\n",(0,l.jsx)(n.h3,{id:"\u7248\u672c\u7684\u9009\u62e9",children:"\u7248\u672c\u7684\u9009\u62e9"}),"\n",(0,l.jsx)(n.p,{children:"Windows\u5e73\u53f0\u548cMac\u5e73\u53f0\u63a8\u8350\u4e0b\u8f7d\u53ef\u6267\u884c\u6587\u4ef6\u7248\uff0cLinux\u5e73\u53f0\u4e0b\u8f7d\u538b\u7f29\u6587\u4ef6\u7248\u3002"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u4e0b\u56fe\u4e2d\u7684\u7248\u672c\u53f7\u53ef\u80fd\u5e76\u4e0d\u662f\u6700\u65b0\u7684\uff0c\u4f46\u603b\u4f53\u6765\u8bf4\u5b89\u88c5\u6559\u7a0b\u662f\u7c7b\u4f3c\u7684\u3002Go\u8bed\u8a00\u66f4\u65b0\u8fed\u4ee3\u6bd4\u8f83\u5feb\uff0c\u63a8\u8350\u4f7f\u7528\u8f83\u65b0\u7248\u672c\uff0c\u4f53\u9a8c\u6700\u65b0\u7279\u6027\u3002"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"download1",src:d(74008).A+"",width:"830",height:"600"})}),"\n",(0,l.jsx)(n.h2,{id:"\u5b89\u88c5",children:"\u5b89\u88c5"}),"\n",(0,l.jsx)(n.h3,{id:"windows\u5b89\u88c5",children:"Windows\u5b89\u88c5"}),"\n",(0,l.jsxs)(n.p,{children:["\u6b64\u5b89\u88c5\u5b9e\u4f8b\u4ee5 ",(0,l.jsx)(n.code,{children:"64\u4f4dWin10"}),"\u7cfb\u7edf\u5b89\u88c5 ",(0,l.jsx)(n.code,{children:"Go1.14.1\u53ef\u6267\u884c\u6587\u4ef6\u7248\u672c"}),"\u4e3a\u4f8b\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u5c06\u4e0a\u4e00\u6b65\u9009\u597d\u7684\u5b89\u88c5\u5305\u4e0b\u8f7d\u5230\u672c\u5730\u3002"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"download2",src:d(69619).A+"",width:"726",height:"492"})}),"\n",(0,l.jsx)(n.p,{children:"\u53cc\u51fb\u4e0b\u8f7d\u597d\u7684\u6587\u4ef6\uff0c\u7136\u540e\u6309\u7167\u4e0b\u56fe\u7684\u6b65\u9aa4\u5b89\u88c5\u5373\u53ef\u3002"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.img,{alt:"install01",src:d(19177).A+"",width:"495",height:"387"}),(0,l.jsx)(n.img,{alt:"install02",src:d(88210).A+"",width:"495",height:"387"}),(0,l.jsx)(n.img,{alt:"install03",src:d(3035).A+"",width:"495",height:"387"}),(0,l.jsx)(n.img,{alt:"install04",src:d(39172).A+"",width:"495",height:"387"}),(0,l.jsx)(n.img,{alt:"install05",src:d(93069).A+"",width:"495",height:"387"})]}),"\n",(0,l.jsx)(n.h3,{id:"linux\u4e0b\u5b89\u88c5",children:"Linux\u4e0b\u5b89\u88c5"}),"\n",(0,l.jsx)(n.p,{children:"\u5982\u679c\u4e0d\u662f\u8981\u5728Linux\u5e73\u53f0\u6572go\u4ee3\u7801\u5c31\u4e0d\u9700\u8981\u5728Linux\u5e73\u53f0\u5b89\u88c5Go\uff0c\u6211\u4eec\u5f00\u53d1\u673a\u4e0a\u5199\u597d\u7684go\u4ee3\u7801\u53ea\u9700\u8981\u8de8\u5e73\u53f0\u7f16\u8bd1\uff08\u8be6\u89c1\u6587\u7ae0\u672b\u5c3e\u7684\u8de8\u5e73\u53f0\u7f16\u8bd1\uff09\u597d\u4e4b\u540e\u5c31\u53ef\u4ee5\u62f7\u8d1d\u5230Linux\u670d\u52a1\u5668\u4e0a\u8fd0\u884c\u4e86\uff0c\u8fd9\u4e5f\u662fgo\u7a0b\u5e8f\u8de8\u5e73\u53f0\u6613\u90e8\u7f72\u7684\u4f18\u52bf\u3002"}),"\n",(0,l.jsxs)(n.p,{children:["\u6211\u4eec\u5728\u7248\u672c\u9009\u62e9\u9875\u9762\u9009\u62e9\u5e76\u4e0b\u8f7d\u597d",(0,l.jsx)(n.code,{children:"go1.14.1.linux-amd64.tar.gz"}),"\u6587\u4ef6\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"wget https://dl.google.com/go/go1.14.1.linux-amd64.tar.gz\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5c06\u4e0b\u8f7d\u597d\u7684\u6587\u4ef6\u89e3\u538b\u5230",(0,l.jsx)(n.code,{children:"/usr/local"}),"\u76ee\u5f55\u4e0b\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tar -zxvf go1.14.1.linux-amd64.tar.gz -C /usr/local # \u89e3\u538b\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u63d0\u793a\u6ca1\u6709\u6743\u9650\uff0c\u52a0\u4e0a",(0,l.jsx)(n.code,{children:"sudo"}),"\u4ee5root\u7528\u6237\u7684\u8eab\u4efd\u518d\u8fd0\u884c\u3002\u6267\u884c\u5b8c\u5c31\u53ef\u4ee5\u5728",(0,l.jsx)(n.code,{children:"/usr/local/"}),"\u4e0b\u770b\u5230",(0,l.jsx)(n.code,{children:"go"}),"\u76ee\u5f55\u4e86\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff1a Linux\u4e0b\u6709\u4e24\u4e2a\u6587\u4ef6\u53ef\u4ee5\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u5176\u4e2d",(0,l.jsx)(n.code,{children:"/etc/profile"}),"\u662f\u5bf9\u6240\u6709\u7528\u6237\u751f\u6548\u7684\uff1b",(0,l.jsx)(n.code,{children:"$HOME/.profile"}),"\u662f\u5bf9\u5f53\u524d\u7528\u6237\u751f\u6548\u7684\uff0c\u6839\u636e\u81ea\u5df1\u7684\u60c5\u51b5\u81ea\u884c\u9009\u62e9\u4e00\u4e2a\u6587\u4ef6\u6253\u5f00\uff0c\u6dfb\u52a0\u5982\u4e0b\u4e24\u884c\u4ee3\u7801\uff0c\u4fdd\u5b58\u9000\u51fa\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"export GOROOT=/usr/local/go\nexport PATH=$PATH:$GOROOT/bin\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u4fee\u6539",(0,l.jsx)(n.code,{children:"/etc/profile"}),"\u540e\u8981\u91cd\u542f\u751f\u6548\uff0c\u4fee\u6539",(0,l.jsx)(n.code,{children:"$HOME/.profile"}),"\u540e\u4f7f\u7528source\u547d\u4ee4\u52a0\u8f7d",(0,l.jsx)(n.code,{children:"$HOME/.profile"}),"\u6587\u4ef6\u5373\u53ef\u751f\u6548\u3002 \u68c0\u67e5\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"~ go version\ngo version go1.14.1 linux/amd64\n"})}),"\n",(0,l.jsx)(n.h3,{id:"mac\u4e0b\u5b89\u88c5",children:"Mac\u4e0b\u5b89\u88c5"}),"\n",(0,l.jsxs)(n.p,{children:["\u4e0b\u8f7d\u53ef\u6267\u884c\u6587\u4ef6\u7248\uff0c\u76f4\u63a5\u70b9\u51fb",(0,l.jsx)(n.strong,{children:"\u4e0b\u4e00\u6b65"}),"\u5b89\u88c5\u5373\u53ef\uff0c\u9ed8\u8ba4\u4f1a\u5c06go\u5b89\u88c5\u5230",(0,l.jsx)(n.code,{children:"/usr/local/go"}),"\u76ee\u5f55\u4e0b\u3002",(0,l.jsx)(n.img,{alt:"Mac\u5b89\u88c5Go",src:d(52055).A+"",width:"620",height:"438"})]}),"\n",(0,l.jsx)(n.h3,{id:"\u68c0\u67e5",children:"\u68c0\u67e5"}),"\n",(0,l.jsxs)(n.p,{children:["\u4e0a\u4e00\u6b65\u5b89\u88c5\u8fc7\u7a0b\u6267\u884c\u5b8c\u6bd5\u540e\uff0c\u53ef\u4ee5\u6253\u5f00\u7ec8\u7aef\u7a97\u53e3\uff0c\u8f93\u5165",(0,l.jsx)(n.code,{children:"go version"}),"\u547d\u4ee4\uff0c\u67e5\u770b\u5b89\u88c5\u7684Go\u7248\u672c\u3002",(0,l.jsx)(n.img,{alt:"install06",src:d(79094).A+"",width:"689",height:"430"})]}),"\n",(0,l.jsx)(n.h2,{id:"goroot\u548cgopath",children:"GOROOT\u548cGOPATH"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"GOROOT"}),"\u548c",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u90fd\u662f\u73af\u5883\u53d8\u91cf\uff0c\u5176\u4e2d",(0,l.jsx)(n.code,{children:"GOROOT"}),"\u662f\u6211\u4eec\u5b89\u88c5go\u5f00\u53d1\u5305\u7684\u8def\u5f84\uff0c\u800c\u4eceGo 1.8\u7248\u672c\u5f00\u59cb\uff0cGo\u5f00\u53d1\u5305\u5728\u5b89\u88c5\u5b8c\u6210\u540e\u4f1a\u4e3a",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u8bbe\u7f6e\u4e00\u4e2a\u9ed8\u8ba4\u76ee\u5f55\uff0c\u5e76\u4e14\u5728Go1.14\u53ca\u4e4b\u540e\u7684\u7248\u672c\u4e2d\u542f\u7528\u4e86Go Module\u6a21\u5f0f\u4e4b\u540e\uff0c\u4e0d\u4e00\u5b9a\u975e\u8981\u5c06\u4ee3\u7801\u5199\u5230GOPATH\u76ee\u5f55\u4e0b\uff0c\u6240\u4ee5\u4e5f\u5c31",(0,l.jsx)(n.strong,{children:"\u4e0d\u9700\u8981\u6211\u4eec\u518d\u81ea\u5df1\u914d\u7f6eGOPATH"}),"\u4e86\uff0c\u4f7f\u7528\u9ed8\u8ba4\u7684\u5373\u53ef\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u60f3\u8981\u67e5\u770b\u4f60\u7535\u8111\u4e0a\u7684",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u8def\u5f84\uff0c\u53ea\u9700\u8981\u6253\u5f00\u7ec8\u7aef\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5e76\u56de\u8f66\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"go env\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5728\u7ec8\u7aef\u8f93\u51fa\u7684\u5185\u5bb9\u4e2d\u627e\u5230",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u5bf9\u5e94\u7684\u5177\u4f53\u8def\u5f84\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"goproxy-\u975e\u5e38\u91cd\u8981",children:"GOPROXY \u975e\u5e38\u91cd\u8981"}),"\n",(0,l.jsxs)(n.p,{children:["Go1.14\u7248\u672c\u4e4b\u540e\uff0c\u90fd\u63a8\u8350\u4f7f\u7528",(0,l.jsx)(n.code,{children:"go mod"}),"\u6a21\u5f0f\u6765\u7ba1\u7406\u4f9d\u8d56\u73af\u5883\u4e86\uff0c\u4e5f\u4e0d\u518d\u5f3a\u5236\u6211\u4eec\u628a\u4ee3\u7801\u5fc5\u987b\u5199\u5728",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u4e0b\u9762\u7684src\u76ee\u5f55\u4e86\uff0c\u4f60\u53ef\u4ee5\u5728\u4f60\u7535\u8111\u7684\u4efb\u610f\u4f4d\u7f6e\u7f16\u5199go\u4ee3\u7801\u3002\uff08\u7f51\u4e0a\u6709\u4e9b\u6559\u7a0b\u9002\u7528\u4e8e1.11\u7248\u672c\u4e4b\u524d\u3002\uff09"]}),"\n",(0,l.jsxs)(n.p,{children:["\u9ed8\u8ba4GoPROXY\u914d\u7f6e\u662f\uff1a",(0,l.jsx)(n.code,{children:"GOPROXY=https://proxy.golang.org,direct"}),"\uff0c\u7531\u4e8e\u56fd\u5185\u8bbf\u95ee\u4e0d\u5230",(0,l.jsx)(n.code,{children:"https://proxy.golang.org"}),"\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u6362\u4e00\u4e2aPROXY\uff0c\u8fd9\u91cc\u63a8\u8350\u4f7f\u7528",(0,l.jsx)(n.code,{children:"https://goproxy.io"}),"\u6216",(0,l.jsx)(n.code,{children:"https://goproxy.cn"}),"\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u53ef\u4ee5\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u4fee\u6539GOPROXY\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"go env -w GOPROXY=https://goproxy.cn,direct\n"})}),"\n",(0,l.jsx)(n.h2,{id:"go\u5f00\u53d1\u7f16\u8f91\u5668",children:"Go\u5f00\u53d1\u7f16\u8f91\u5668"}),"\n",(0,l.jsxs)(n.p,{children:["Go\u91c7\u7528\u7684\u662fUTF-8\u7f16\u7801\u7684\u6587\u672c\u6587\u4ef6\u5b58\u653e\u6e90\u4ee3\u7801\uff0c\u7406\u8bba\u4e0a\u4f7f\u7528\u4efb\u4f55\u4e00\u6b3e\u6587\u672c\u7f16\u8f91\u5668\u90fd\u53ef\u4ee5\u505aGo\u8bed\u8a00\u5f00\u53d1\uff0c\u8fd9\u91cc\u63a8\u8350\u4f7f\u7528",(0,l.jsx)(n.code,{children:"VS Code"}),"\u548c",(0,l.jsx)(n.code,{children:"Goland"}),"\u3002 ",(0,l.jsx)(n.code,{children:"VS Code"}),"\u662f\u5fae\u8f6f\u5f00\u6e90\u7684\u7f16\u8f91\u5668\uff0c\u800c",(0,l.jsx)(n.code,{children:"Goland"}),"\u662fjetbrains\u51fa\u54c1\u7684\u4ed8\u8d39IDE\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u6211\u4eec\u8fd9\u91cc\u4f7f\u7528",(0,l.jsx)(n.code,{children:"VS Code"})," \u52a0\u63d2\u4ef6\u505a\u4e3ago\u8bed\u8a00\u7684\u5f00\u53d1\u5de5\u5177\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"vs-code\u4ecb\u7ecd",children:"VS Code\u4ecb\u7ecd"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"VS Code"}),"\u5168\u79f0",(0,l.jsx)(n.code,{children:"Visual Studio Code"}),"\uff0c\u662f\u5fae\u8f6f\u516c\u53f8\u5f00\u6e90\u7684\u4e00\u6b3e",(0,l.jsx)(n.strong,{children:"\u514d\u8d39"}),"\u73b0\u4ee3\u5316\u8f7b\u91cf\u7ea7\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u652f\u6301\u51e0\u4e4e\u6240\u6709\u4e3b\u6d41\u7684\u5f00\u53d1\u8bed\u8a00\u7684\u8bed\u6cd5\u9ad8\u4eae\u3001\u667a\u80fd\u4ee3\u7801\u8865\u5168\u3001\u81ea\u5b9a\u4e49\u70ed\u952e\u3001\u62ec\u53f7\u5339\u914d\u3001\u4ee3\u7801\u7247\u6bb5\u3001\u4ee3\u7801\u5bf9\u6bd4 Diff\u3001GIT \u7b49\u7279\u6027\uff0c\u652f\u6301\u63d2\u4ef6\u6269\u5c55\uff0c\u652f\u6301 Win\u3001Mac \u4ee5\u53ca Linux\u5e73\u53f0\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u867d\u7136\u4e0d\u5982\u67d0\u4e9bIDE\u529f\u80fd\u5f3a\u5927\uff0c\u4f46\u662f\u5b83\u6dfb\u52a0Go\u6269\u5c55\u63d2\u4ef6\u540e\u5df2\u7ecf\u8db3\u591f\u80dc\u4efb\u6211\u4eec\u65e5\u5e38\u7684Go\u5f00\u53d1\u3002"}),"\n",(0,l.jsx)(n.h3,{id:"\u4e0b\u8f7d\u4e0e\u5b89\u88c5",children:"\u4e0b\u8f7d\u4e0e\u5b89\u88c5"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"VS Code"}),"\u5b98\u65b9\u4e0b\u8f7d\u5730\u5740\uff1a",(0,l.jsx)(n.a,{href:"https://code.visualstudio.com/Download",children:"https://code.visualstudio.com/Download"})]}),"\n",(0,l.jsxs)(n.p,{children:["\u4e09\u5927\u4e3b\u6d41\u5e73\u53f0\u90fd\u652f\u6301\uff0c\u8bf7\u6839\u636e\u81ea\u5df1\u7684\u7535\u8111\u5e73\u53f0\u9009\u62e9\u5bf9\u5e94\u7684\u5b89\u88c5\u5305\u3002",(0,l.jsx)(n.img,{alt:"vscode_home",src:d(91581).A+"",width:"914",height:"516"}),"\u53cc\u51fb\u4e0b\u8f7d\u597d\u7684\u5b89\u88c5\u6587\u4ef6\uff0c\u53cc\u51fb\u5b89\u88c5\u5373\u53ef\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"\u914d\u7f6e",children:"\u914d\u7f6e"}),"\n",(0,l.jsx)(n.h4,{id:"\u5b89\u88c5\u4e2d\u6587\u7b80\u4f53\u63d2\u4ef6",children:"\u5b89\u88c5\u4e2d\u6587\u7b80\u4f53\u63d2\u4ef6"}),"\n",(0,l.jsxs)(n.p,{children:["\u70b9\u51fb\u5de6\u4fa7\u83dc\u5355\u680f\u6700\u540e\u4e00\u9879",(0,l.jsx)(n.code,{children:"\u7ba1\u7406\u6269\u5c55"}),"\uff0c\u5728",(0,l.jsx)(n.code,{children:"\u641c\u7d22\u6846"}),"\u4e2d\u8f93\u5165",(0,l.jsx)(n.code,{children:"chinese"})," \uff0c\u9009\u4e2d\u7ed3\u679c\u5217\u8868\u7b2c\u4e00\u9879\uff0c\u70b9\u51fb",(0,l.jsx)(n.code,{children:"install"}),"\u5b89\u88c5\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u5b89\u88c5\u5b8c\u6bd5\u540e\u53f3\u4e0b\u89d2\u4f1a\u63d0\u793a",(0,l.jsx)(n.code,{children:"\u91cd\u542fVS Code"}),"\uff0c\u91cd\u542f\u4e4b\u540e\u4f60\u7684VS Code\u5c31\u663e\u793a\u4e2d\u6587\u5566\uff01",(0,l.jsx)(n.img,{alt:"\u5b89\u88c5\u7b80\u4f53\u4e2d\u6587\u63d2\u4ef6",src:d(48021).A+"",width:"1214",height:"925"}),(0,l.jsx)(n.code,{children:"VSCode"}),"\u4e3b\u754c\u9762\u4ecb\u7ecd\uff1a",(0,l.jsx)(n.img,{alt:"vscode_menu",src:d(89705).A+"",width:"1232",height:"768"})]}),"\n",(0,l.jsx)(n.h4,{id:"\u5b89\u88c5go\u6269\u5c55",children:"\u5b89\u88c5go\u6269\u5c55"}),"\n",(0,l.jsxs)(n.p,{children:["\u73b0\u5728\u6211\u4eec\u8981\u4e3a\u6211\u4eec\u7684VS Code\u7f16\u8f91\u5668\u5b89\u88c5",(0,l.jsx)(n.code,{children:"Go"}),"\u6269\u5c55\u63d2\u4ef6\uff0c\u8ba9\u5b83\u652f\u6301Go\u8bed\u8a00\u5f00\u53d1\u3002",(0,l.jsx)(n.img,{alt:"\u5b89\u88c5go\u6269\u5c55\u56fe",src:d(61145).A+"",width:"1232",height:"932"})]}),"\n",(0,l.jsx)(n.h2,{id:"\u7b2c\u4e00\u4e2ago\u7a0b\u5e8f",children:"\u7b2c\u4e00\u4e2aGo\u7a0b\u5e8f"}),"\n",(0,l.jsx)(n.h3,{id:"hello-world",children:"Hello World"}),"\n",(0,l.jsxs)(n.p,{children:["\u73b0\u5728\u6211\u4eec\u6765\u521b\u5efa\u7b2c\u4e00\u4e2aGo\u9879\u76ee\u2014\u2014",(0,l.jsx)(n.code,{children:"hello"}),"\u3002\u5728\u6211\u4eec\u684c\u9762\u521b\u5efa\u4e00\u4e2a",(0,l.jsx)(n.code,{children:"hello"}),"\u76ee\u5f55\u3002"]}),"\n",(0,l.jsx)(n.h4,{id:"go-mod-init",children:"go mod init"}),"\n",(0,l.jsxs)(n.p,{children:["\u4f7f\u7528go module\u6a21\u5f0f\u65b0\u5efa\u9879\u76ee\u65f6\uff0c\u6211\u4eec",(0,l.jsx)(n.strong,{children:"\u9700\u8981"}),"\u901a\u8fc7",(0,l.jsx)(n.code,{children:"go mod init \u9879\u76ee\u540d"}),"\u547d\u4ee4\u5bf9\u9879\u76ee\u8fdb\u884c\u521d\u59cb\u5316\uff0c\u8be5\u547d\u4ee4\u4f1a\u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u751f\u6210",(0,l.jsx)(n.code,{children:"go.mod"}),"\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u4f7f\u7528",(0,l.jsx)(n.code,{children:"hello"}),"\u4f5c\u4e3a\u6211\u4eec\u7b2c\u4e00\u4e2aGo\u9879\u76ee\u7684\u540d\u79f0\uff0c\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"go mod init hello\n"})}),"\n",(0,l.jsx)(n.h4,{id:"\u7f16\u5199\u4ee3\u7801",children:"\u7f16\u5199\u4ee3\u7801"}),"\n",(0,l.jsxs)(n.p,{children:["\u63a5\u4e0b\u6765\u5728\u8be5\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a",(0,l.jsx)(n.code,{children:"main.go"}),"\u6587\u4ef6\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-go",children:'package main // \u58f0\u660e main \u5305\uff0c\u8868\u660e\u5f53\u524d\u662f\u4e00\u4e2a\u53ef\u6267\u884c\u7a0b\u5e8f\n\nimport "fmt" // \u5bfc\u5165\u5185\u7f6e fmt \u5305\n\nfunc main(){ // main\u51fd\u6570\uff0c\u662f\u7a0b\u5e8f\u6267\u884c\u7684\u5165\u53e3\n\tfmt.Println("Hello World!") // \u5728\u7ec8\u7aef\u6253\u5370 Hello World!\n}\n'})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u975e\u5e38\u91cd\u8981\uff01\uff01\uff01"})," \u5982\u679c\u6b64\u65f6VS Code\u53f3\u4e0b\u89d2\u5f39\u51fa\u63d0\u793a\u8ba9\u4f60\u5b89\u88c5\u63d2\u4ef6\uff0c\u52a1\u5fc5\u70b9 ",(0,l.jsx)(n.strong,{children:"install all"})," \u8fdb\u884c\u5b89\u88c5\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u8fd9\u4e00\u6b65\u9700\u8981\u5148\u6267\u884c\u5b8c\u4e0a\u9762\u63d0\u5230\u7684",(0,l.jsx)(n.code,{children:"go env -w GOPROXY=https://goproxy.cn,direct"}),"\u547d\u4ee4\u914d\u7f6e\u597d",(0,l.jsx)(n.code,{children:"GOPROXY"}),"\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"\u7f16\u8bd1",children:"\u7f16\u8bd1"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"go build"}),"\u547d\u4ee4\u8868\u793a\u5c06\u6e90\u4ee3\u7801\u7f16\u8bd1\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u5728hello\u76ee\u5f55\u4e0b\u6267\u884c\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"go build\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u7f16\u8bd1\u5f97\u5230\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4f1a\u4fdd\u5b58\u5728\u6267\u884c\u7f16\u8bd1\u547d\u4ee4\u7684\u5f53\u524d\u76ee\u5f55\u4e0b\uff0c\u5982\u679c\u662f",(0,l.jsx)(n.code,{children:"Windows"}),"\u5e73\u53f0\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u627e\u5230",(0,l.jsx)(n.code,{children:"hello.exe"}),"\u53ef\u6267\u884c\u6587\u4ef6\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u53ef\u5728\u7ec8\u7aef\u76f4\u63a5\u6267\u884c\u8be5",(0,l.jsx)(n.code,{children:"hello.exe"}),"\u6587\u4ef6\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"c:\\desktop\\hello>hello.exe\nHello World!\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528",(0,l.jsx)(n.code,{children:"-o"}),"\u53c2\u6570\u6765\u6307\u5b9a\u7f16\u8bd1\u540e\u5f97\u5230\u7684\u53ef\u6267\u884c\u6587\u4ef6\u7684\u540d\u5b57\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"go build -o heiheihei.exe\n"})}),"\n",(0,l.jsx)(n.h3,{id:"windows\u4e0bvscode\u5207\u6362cmdexe\u4f5c\u4e3a\u9ed8\u8ba4\u7ec8\u7aef",children:"Windows\u4e0bVSCode\u5207\u6362cmd.exe\u4f5c\u4e3a\u9ed8\u8ba4\u7ec8\u7aef"}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u4f60\u6253\u5f00VS Code\u7684\u7ec8\u7aef\u754c\u9762\u51fa\u73b0\u5982\u4e0b\u56fe\u573a\u666f\uff08\u6ce8\u610f\u89c2\u5bdf\u7ea2\u6846\u5708\u4e2d\u90e8\u5206\uff09\uff0c\u90a3\u4e48\u4f60\u7684",(0,l.jsx)(n.code,{children:"VS Code"}),"\u6b64\u65f6\u6b63\u4f7f\u7528",(0,l.jsx)(n.code,{children:"powershell"}),"\u4f5c\u4e3a\u9ed8\u8ba4\u7ec8\u7aef\uff1a",(0,l.jsx)(n.img,{alt:"vscode shell\u914d\u7f6e1",src:d(83879).A+"",width:"1310",height:"569"}),"\u5341\u5206\u63a8\u8350\u4f60\u6309\u7167\u4e0b\u9762\u7684\u6b65\u9aa4\uff0c\u9009\u62e9",(0,l.jsx)(n.code,{children:"cmd.exe"}),"\u4f5c\u4e3a\u9ed8\u8ba4\u7684\u7ec8\u7aef\u5de5\u5177\uff1a",(0,l.jsx)(n.img,{alt:"vscode shell\u914d\u7f6e2",src:d(64876).A+"",width:"1310",height:"540"}),"\u6b64\u65f6\uff0cVS Code\u6b63\u4e0a\u65b9\u4e2d\u95f4\u4f4d\u7f6e\u4f1a\u5f39\u51fa\u5982\u4e0b\u754c\u9762\uff0c\u53c2\u7167\u4e0b\u56fe\u632a\u52a8\u9f20\u6807\u4f7f\u5149\u6807\u9009\u4e2d\u540e\u7f00\u4e3a",(0,l.jsx)(n.code,{children:"cmd.exe"}),"\u7684\u90a3\u4e00\u4e2a\uff0c\u7136\u540e\u70b9\u51fb\u9f20\u6807\u5de6\u952e\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u6700\u540e",(0,l.jsx)(n.strong,{children:"\u91cd\u542fVS Code\u4e2d\u5df2\u7ecf\u6253\u5f00\u7684\u7ec8\u7aef"}),"\u6216\u8005",(0,l.jsx)(n.strong,{children:"\u76f4\u63a5\u91cd\u542fVS Code"}),"\u5c31\u53ef\u4ee5\u4e86\u3002",(0,l.jsx)(n.img,{alt:"vscode shell\u914d\u7f6e3",src:d(17141).A+"",width:"1310",height:"357"}),"\u5982\u679c\u6ca1\u6709\u51fa\u73b0\u4e0b\u62c9\u4e09\u89d2\uff0c\u4e5f\u6ca1\u6709\u5173\u7cfb\uff0c\u6309\u4e0b",(0,l.jsx)(n.code,{children:"Ctrl+Shift+P"}),"\uff0cVS Code\u6b63\u4e0a\u65b9\u4f1a\u51fa\u73b0\u4e00\u4e2a\u6846\uff0c\u4f60\u6309\u7167\u4e0b\u56fe\u8f93\u5165",(0,l.jsx)(n.code,{children:"shell"}),"\uff0c\u7136\u540e\u70b9\u51fb\u6307\u5b9a\u9009\u9879\u5373\u53ef\u51fa\u73b0\u4e0a\u9762\u7684\u754c\u9762\u4e86\u3002",(0,l.jsx)(n.img,{alt:"vscode shell\u914d\u7f6e4",src:d(77018).A+"",width:"1310",height:"356"})]}),"\n",(0,l.jsx)(n.h3,{id:"go-run",children:"go run"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"go run main.go"}),"\u4e5f\u53ef\u4ee5\u6267\u884c\u7a0b\u5e8f\uff0c\u8be5\u547d\u4ee4\u672c\u8d28\u4e0a\u662f\u5148\u5728\u4e34\u65f6\u76ee\u5f55\u7f16\u8bd1\u7a0b\u5e8f\u7136\u540e\u518d\u6267\u884c\u3002"]}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u4f60\u4e0d\u6e05\u695a\u4e0a\u65b9\u5173\u4e8e",(0,l.jsx)(n.code,{children:"go run"}),"\u6267\u884c\u673a\u5236\u7684\u63cf\u8ff0\uff0c\u90a3\u4e48\u4f60\u6700\u597d\u4eca\u540e\u90fd\u4f7f\u7528",(0,l.jsx)(n.code,{children:"go build"}),"\u7f16\u8bd1\u518d\u6267\u884c\u3002"]}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"go-install",children:"go install"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"go install"}),"\u8868\u793a\u5b89\u88c5\u7684\u610f\u601d\uff0c\u5b83\u5148\u7f16\u8bd1\u6e90\u4ee3\u7801\u5f97\u5230\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u7136\u540e\u5c06\u53ef\u6267\u884c\u6587\u4ef6\u79fb\u52a8\u5230",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u7684bin\u76ee\u5f55\u4e0b\u3002\u56e0\u4e3a\u6211\u4eec",(0,l.jsxs)(n.strong,{children:["\u628a",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u4e0b\u7684",(0,l.jsx)(n.code,{children:"bin"}),"\u76ee\u5f55\u6dfb\u52a0\u5230\u4e86\u73af\u5883\u53d8\u91cf\u4e2d"]}),"\uff0c\u6240\u4ee5\u6211\u4eec\u5c31\u53ef\u4ee5\u5728\u4efb\u610f\u5730\u65b9\u76f4\u63a5\u6267\u884c\u53ef\u6267\u884c\u6587\u4ef6\u4e86\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"\u8de8\u5e73\u53f0\u7f16\u8bd1",children:"\u8de8\u5e73\u53f0\u7f16\u8bd1"}),"\n",(0,l.jsxs)(n.p,{children:["\u9ed8\u8ba4\u6211\u4eec",(0,l.jsx)(n.code,{children:"go build"}),"\u7684\u53ef\u6267\u884c\u6587\u4ef6\u90fd\u662f\u5f53\u524d\u64cd\u4f5c\u7cfb\u7edf\u53ef\u6267\u884c\u7684\u6587\u4ef6\uff0cGo\u8bed\u8a00\u652f\u6301\u8de8\u5e73\u53f0\u7f16\u8bd1\u2014\u2014\u5728\u5f53\u524d\u5e73\u53f0\uff08\u4f8b\u5982Windows\uff09\u4e0b\u7f16\u8bd1\u5176\u4ed6\u5e73\u53f0\uff08\u4f8b\u5982Linux\uff09\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002"]}),"\n",(0,l.jsx)(n.h4,{id:"windows\u7f16\u8bd1linux\u53ef\u6267\u884c\u6587\u4ef6",children:"Windows\u7f16\u8bd1Linux\u53ef\u6267\u884c\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:"\u5982\u679c\u6211\u60f3\u5728Windows\u4e0b\u7f16\u8bd1\u4e00\u4e2aLinux\u4e0b\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u90a3\u9700\u8981\u600e\u4e48\u505a\u5462\uff1f\u53ea\u9700\u8981\u5728\u7f16\u8bd1\u65f6\u6307\u5b9a\u76ee\u6807\u64cd\u4f5c\u7cfb\u7edf\u7684\u5e73\u53f0\u548c\u5904\u7406\u5668\u67b6\u6784\u5373\u53ef\u3002"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsxs)(n.p,{children:["\u6ce8\u610f\uff1a\u65e0\u8bba\u4f60\u5728Windows\u7535\u8111\u4e0a\u4f7f\u7528VsCode\u7f16\u8f91\u5668\u8fd8\u662fGoland\u7f16\u8f91\u5668\uff0c\u90fd\u8981\u6ce8\u610f\u4f60\u4f7f\u7528\u7684\u7ec8\u7aef\u7c7b\u578b\uff0c\u56e0\u4e3a\u4e0d\u540c\u7684\u7ec8\u7aef\u4e0b\u547d\u4ee4\u4e0d\u4e00\u6837\uff01\uff01\uff01\u76ee\u524d\u7684Windows\u901a\u5e38\u9ed8\u8ba4\u4f7f\u7528\u7684\u662f",(0,l.jsx)(n.code,{children:"PowerShell"}),"\u7ec8\u7aef\u3002"]}),"\n"]}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u4f60\u7684",(0,l.jsx)(n.code,{children:"Windows"}),"\u4f7f\u7528\u7684\u662f",(0,l.jsx)(n.code,{children:"cmd"}),"\uff0c\u90a3\u4e48\u6309\u5982\u4e0b\u65b9\u5f0f\u6307\u5b9a\u73af\u5883\u53d8\u91cf\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"SET CGO_ENABLED=0 // \u7981\u7528CGO\nSET GOOS=linux // \u76ee\u6807\u5e73\u53f0\u662flinux\nSET GOARCH=amd64 // \u76ee\u6807\u5904\u7406\u5668\u67b6\u6784\u662famd64\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u4f60\u7684",(0,l.jsx)(n.code,{children:"Windows"}),"\u4f7f\u7528\u7684\u662f",(0,l.jsx)(n.code,{children:"PowerShell"}),"\u7ec8\u7aef\uff0c\u90a3\u4e48\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u7684\u8bed\u6cd5\u4e3a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:'$ENV:CGO_ENABLED=0\n$ENV:GOOS="linux"\n$ENV:GOARCH="amd64"\n'})}),"\n",(0,l.jsxs)(n.p,{children:["\u5728\u4f60\u7684",(0,l.jsx)(n.code,{children:"Windows"}),"\u7ec8\u7aef\u4e0b\u6267\u884c\u5b8c\u4e0a\u8ff0\u547d\u4ee4\u540e\uff0c\u518d\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff0c\u5f97\u5230\u7684\u5c31\u662f\u80fd\u591f\u5728Linux\u5e73\u53f0\u8fd0\u884c\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4e86\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"go build\n"})}),"\n",(0,l.jsx)(n.h4,{id:"windows\u7f16\u8bd1mac\u53ef\u6267\u884c\u6587\u4ef6",children:"Windows\u7f16\u8bd1Mac\u53ef\u6267\u884c\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:"Windows\u4e0b\u7f16\u8bd1Mac\u5e73\u53f064\u4f4d\u53ef\u6267\u884c\u7a0b\u5e8f\uff1a"}),"\n",(0,l.jsx)(n.p,{children:"cmd\u7ec8\u7aef\u4e0b\u6267\u884c\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"SET CGO_ENABLED=0\nSET GOOS=darwin\nSET GOARCH=amd64\ngo build\n"})}),"\n",(0,l.jsx)(n.p,{children:"PowerShell\u7ec8\u7aef\u4e0b\u6267\u884c\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:'$ENV:CGO_ENABLED=0\n$ENV:GOOS="darwin"\n$ENV:GOARCH="amd64"\ngo build\n'})}),"\n",(0,l.jsx)(n.h4,{id:"mac\u7f16\u8bd1linux\u53ef\u6267\u884c\u6587\u4ef6",children:"Mac\u7f16\u8bd1Linux\u53ef\u6267\u884c\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:"Mac\u7535\u8111\u7f16\u8bd1\u5f97\u5230Linux\u5e73\u53f064\u4f4d\u53ef\u6267\u884c\u7a0b\u5e8f\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build\n"})}),"\n",(0,l.jsx)(n.h4,{id:"mac\u7f16\u8bd1windows\u53ef\u6267\u884c\u6587\u4ef6",children:"Mac\u7f16\u8bd1Windows\u53ef\u6267\u884c\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:"Mac\u7535\u8111\u7f16\u8bd1\u5f97\u5230Windows\u5e73\u53f064\u4f4d\u53ef\u6267\u884c\u7a0b\u5e8f\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build\n"})}),"\n",(0,l.jsx)(n.h4,{id:"linux\u7f16\u8bd1mac\u53ef\u6267\u884c\u6587\u4ef6",children:"Linux\u7f16\u8bd1Mac\u53ef\u6267\u884c\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:"Linux\u5e73\u53f0\u4e0b\u7f16\u8bd1Mac\u5e73\u53f064\u4f4d\u53ef\u6267\u884c\u7a0b\u5e8f\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build\n"})}),"\n",(0,l.jsx)(n.h4,{id:"linux\u7f16\u8bd1windows\u53ef\u6267\u884c\u6587\u4ef6",children:"Linux\u7f16\u8bd1Windows\u53ef\u6267\u884c\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:"Linux\u5e73\u53f0\u4e0b\u7f16\u8bd1Windows\u5e73\u53f064\u4f4d\u53ef\u6267\u884c\u7a0b\u5e8f\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u73b0\u5728\uff0c\u5f00\u542f\u4f60\u7684Go\u8bed\u8a00\u5b66\u4e60\u4e4b\u65c5\u5427\u3002\u4eba\u751f\u82e6\u77ed\uff0clet\u2019s Go."})]})}function x(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(a,{...e})}):a(e)}},93069:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/install05-3422b8319492e3836251bcb93731ab7e.png"}}]);