{"id":1590,"date":"2023-12-02T15:31:40","date_gmt":"2023-12-02T07:31:40","guid":{"rendered":"https:\/\/peloo.net\/?p=1590"},"modified":"2024-06-26T00:25:42","modified_gmt":"2024-06-25T16:25:42","slug":"linux%e9%83%a8%e7%bd%b2go%e5%a4%9a%e7%89%88%e6%9c%ac%e5%b7%a5%e5%85%b7g","status":"publish","type":"post","link":"https:\/\/peloo.net\/?p=1590","title":{"rendered":"linux\u90e8\u7f72go\u591a\u7248\u672c\u5de5\u5177g"},"content":{"rendered":"<h1>\u5b89\u88c5<\/h1>\n<pre><code class=\"language-bash\">cd\nmkdir ~\/.g\ncat &lt;&lt; &quot;EOF&quot; | tee ~\/.g\/env\n#!\/bin\/sh\n# g shell setup\nexport GOROOT=&quot;${HOME}\/.g\/go&quot;\nexport PATH=&quot;${HOME}\/.g\/bin:${GOROOT}\/bin:$PATH&quot;\nexport G_MIRROR=https:\/\/golang.google.cn\/dl\/\nEOF\n\ncat &lt;&lt; &quot;EOF&quot; | tee -a ~\/.bashrc\n# g shell setup\nif [ -f &quot;${HOME}\/.g\/env&quot; ]; then\n    . &quot;${HOME}\/.g\/env&quot;\nfi\nEOF\n\nexec bash\n\n# download g\nwget -c https:\/\/mirror.ghproxy.com\/https:\/\/github.com\/voidint\/g\/releases\/download\/v1.6.0\/g1.6.0.linux-amd64.tar.gz\nmkdir ~\/.g\/bin\n# unzip to folder ~\/.g\/bin\ntar xf g1.6.0.linux-amd64.tar.gz -C ~\/.g\/bin\nrm -f g1.6.0.linux-amd64.tar.gz 2&gt;\/dev\/null\nls ~\/.g\/bin\nexec bash\n# list current env\ng ls\n# list remote go versions\ng ls-remote\ng ls-remote stable\n# install go version\ng install 1.20.11\ng install 1.21.4\n# activate go version\ng use 1.20.11\ng clean\n# update g\ng self update\n# remove g\ng self uninstall\n<\/code><\/pre>\n<h1>FAQ<\/h1>\n<h2>\u5b89\u88c5go\u7248\u672c\u62a5\u9519[g] Url &quot;<a href=\"https:\/\/golang.google.cn\/dl\/\">https:\/\/golang.google.cn\/dl\/<\/a>&quot; is unreachable ==&gt; Get &quot;<a href=\"https:\/\/golang.google.cn\/dl\/\">https:\/\/golang.google.cn\/dl\/<\/a>&quot;: net\/http: TLS handshake timeout<\/h2>\n<p>\u9700\u8981\u68af\u5b50\u8bbf\u95eeGoogle\u624d\u884c\uff0c\u800c\u4e14\u8fd8\u8981\u5f00\u5168\u5c40\u4ee3\u7406\u3002<\/p>\n<h2>\u4e3ago\u8bbe\u7f6e\u56fd\u5185\u4ee3\u7406<\/h2>\n<pre><code class=\"language-bash\">go env -w GO111MODULE=on\ngo env -w GOPROXY=https:\/\/goproxy.cn,direct<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5 cd mkdir ~\/.g cat &lt;&lt; &quot;EOF&quot; | tee ~\/.g\/env #!\/bin\/sh # g shell setup export GOROOT=&quot;${HOME}\/.g\/go&quot; export PATH=&quot;${HOME}\/.g\/bin:${GOROOT}\/bin:$PATH&quot; export G_MIRROR=https:\/\/golang.google.cn\/dl\/ EOF cat &lt;&lt; &quot;EOF&quot; | tee -a ~\/.bashrc # g shell setup if [ -f &quot;${HOME}\/.g\/env&quot; ]; then . &quot;${HOME}\/.g\/env&quot; fi EOF exec bash # download g wget -c https:\/\/mirror.ghproxy.com\/https:\/\/github.com\/voidint\/g\/releases\/download\/v1.6.0\/g1.6.0.linux-amd64.tar.gz mkdir ~\/.g\/bin # unzip&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/posts\/1590"}],"collection":[{"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/peloo.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1590"}],"version-history":[{"count":9,"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/posts\/1590\/revisions"}],"predecessor-version":[{"id":1649,"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/posts\/1590\/revisions\/1649"}],"wp:attachment":[{"href":"https:\/\/peloo.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1590"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peloo.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1590"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peloo.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1590"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}