{"id":327,"date":"2021-06-26T14:10:56","date_gmt":"2021-06-26T06:10:56","guid":{"rendered":"https:\/\/www.iotot.com\/?p=327"},"modified":"2022-05-22T11:23:46","modified_gmt":"2022-05-22T03:23:46","slug":"ubuntu-%e6%90%ad%e5%bb%bago%e5%bc%80%e5%8f%91%e7%8e%af%e5%a2%83","status":"publish","type":"post","link":"https:\/\/blog.iotot.com\/?p=327","title":{"rendered":"Ubuntu \u642d\u5efaGO\u5f00\u53d1\u73af\u5883"},"content":{"rendered":"\n<p>1\u3001go\u5f00\u53d1\u73af\u5883\u7684\u4e0b\u8f7d\u7f51\u5740: https:\/\/golang.google.cn\/dl\/<br>ubuntu\u5c31\u4e0b\u8f7dlinux\u7684<\/p>\n\n\n\n<p>2\u3001\u7136\u540e\u627e\u5230\u521a\u624d\u7684\u4e0b\u8f7d\u76ee\u5f55,\u5c06\u4e0b\u8f7d\u7684\u4e8c\u8fdb\u5236\u5305\u89e3\u538b\u81f3 \/usr\/local\u76ee\u5f55<\/p>\n\n\n\n<p><code>tar -C \/usr\/local -xzf go1.12.7.linux-amd64.tar.gz<\/code><\/p>\n\n\n\n<p>3\u3001\u6dfb\u52a0GOPATH(GOPATH\u4e3a\u81ea\u5df1\u521b\u5efa\u7684\u5b58\u653eGO\u9879\u76ee\u7684\u5de5\u4f5c\u76ee\u5f55[\u4e0d\u5efa\u8bae\u540cGOROOT\u4e3a\u540c\u4e00\u4e2a\u8def\u5f84],\u53ef\u4ee5\u6709\u591a\u4e2a,\u4ee5:\u5206\u9694,\u4f46\u662f\u4f7f\u7528go get \u4e0b\u8f7d\u7684\u5305\u9ed8\u8ba4\u4f1a\u88c5\u5230\u7b2c\u4e00\u4e2aGOPATH\u4e0b)<\/p>\n\n\n\n<p><code>export GOPATH=$HOME\/Go<\/code><\/p>\n\n\n\n<p>4\u3001\u6dfb\u52a0GOROOT<\/p>\n\n\n\n<p><code>export GOROOT=\/usr\/local\/go<\/code><\/p>\n\n\n\n<p>5\u3001\u6dfb\u52a0PATH<\/p>\n\n\n\n<p><code>export PATH=$PATH:$GOROOT\/bin:$GOPATH\/bin<\/code><\/p>\n\n\n\n<p>6\u3001Go\u9879\u76ee\u5fc5\u987b\u4e0b\u8f7d\u5230GOPATH\u4e0b\u7684github.com\u8def\u5f84\u4e0b,\u60f3\u8981\u5728\u4efb\u4f55\u5730\u65b9\u8fd0\u884cgo\u9879\u76ee,\u53ef\u4ee5\u8fd9\u6837\u8bbe\u7f6e<\/p>\n\n\n\n<p><code>export GO111MODULE=\"on\"<\/code><\/p>\n\n\n\n<p>7\u3001\u67d0\u4e9b\u5305\u7531\u4e8e\u957f\u57ce\u592a\u9ad8\u88ab\u5899\u6321\u4f4f\u4e86,\u53ef\u4ee5\u914d\u7f6e\u5982\u4e0b,\u8f7b\u677e\u62c9\u53d6\u4e4b\u524d\u62c9\u4e0d\u4e0b\u6765\u7684\u5305<\/p>\n\n\n\n<p><code>export GOPROXY=https:\/\/goproxy.io<\/code><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>\u4ee5\u4e0a\u65b9\u6cd5\u53c2\u6570\u662f\u4e34\u65f6\u6709\u6548\uff0c\u5982\u679c\u9700\u8981\u957f\u671f\u4f7f\u7528\uff0c\u9700\u8981\u65b0\u589e\u5230\u73af\u5883\u53d8\u91cf\u6587\u4ef6<\/strong><\/p>\n\n\n\n<p><code>sudo gedit ~\/.profile<\/code><\/p>\n\n\n\n<p>\u4f7f\u6587\u4ef6\u7acb\u523b\u751f\u6548\uff0c<code>$ source ~\/.profile<\/code>\u91cd\u542f\u7cfb\u7edf\u5373\u53ef<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001go\u5f00\u53d1\u73af\u5883\u7684\u4e0b\u8f7d\u7f51\u5740: https:\/\/golang.google.cn\/dl\/ubuntu\u5c31\u4e0b\u8f7dlin [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":848,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.iotot.com\/index.php?rest_route=\/wp\/v2\/posts\/327"}],"collection":[{"href":"https:\/\/blog.iotot.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.iotot.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.iotot.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.iotot.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=327"}],"version-history":[{"count":5,"href":"https:\/\/blog.iotot.com\/index.php?rest_route=\/wp\/v2\/posts\/327\/revisions"}],"predecessor-version":[{"id":333,"href":"https:\/\/blog.iotot.com\/index.php?rest_route=\/wp\/v2\/posts\/327\/revisions\/333"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.iotot.com\/index.php?rest_route=\/wp\/v2\/media\/848"}],"wp:attachment":[{"href":"https:\/\/blog.iotot.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=327"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.iotot.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=327"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.iotot.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=327"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}