| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
mwrx6905
9年前发布

Mac上go环境配置

   <h2>使用Homebrew 安装go语言sdk</h2>    <p> </p>    <blockquote>     <p>brew install go</p>    </blockquote>    <p>==> Downloading <a href="/misc/goto?guid=4959670653644424031">https://homebrew.bintray.com/bottles/go-1.5.1.el_capitan.bottle.</a><br> Already downloaded: /Library/Caches/Homebrew/go-1.5.1.el_capitan.bottle.tar.gz<br> ==> Pouring go-1.5.1.el_capitan.bottle.tar.gz<br> ==> Caveats<br> As of go 1.2, a valid GOPATH is required to use the <code>go get</code> command:<br> <a href="/misc/goto?guid=4959670653736572787">https://golang.org/doc/code.html#GOPATH</a></p>    <p>You may wish to add the GOROOT-based install location to your PATH:<br> export PATH=$PATH:/usr/local/opt/go/libexec/bin<br> ==> Summary<br> ? /usr/local/Cellar/go/1.5.1: 5330 files, 273M</p>    <h2>配置GOPATH</h2>    <p>查看go 的环境变量设置</p>    <blockquote>     <p>go env</p>    </blockquote>    <pre>  GOARCH="amd64"  GOBIN=""  GOEXE=""  GOHOSTARCH="amd64"  GOHOSTOS="darwin"  GOOS="darwin"  GOPATH=""  GORACE=""  GOROOT="/usr/local/Cellar/go/1.5.1/libexec"  GOTOOLDIR="/usr/local/Cellar/go/1.5.1/libexec/pkg/tool/darwin_amd64"  GO15VENDOREXPERIMENT=""  CC="clang"  GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"  CXX="clang++"  CGO_ENABLED="1"  </pre>    <p>需要设置环境变量<code>GOPATH</code> ,<code>GOBIN</code> 以及把GOBIN加入到<code>PATH</code>中</p>    <p>在fishshell设置GOPATH<br> <code>set -gx GOPATH /usr/local/Cellar/go/1.5.1</code></p>    <blockquote>     <p>vim .bash_profile</p>    </blockquote>    <pre>  export GOPATH=/usr/local/Cellar/go/1.5.1  export GOBIN=$GOPATH/bin  export PATH=$PATH:$GOBIN  </pre>    <blockquote>     <p>source .bash_profile</p>    </blockquote>    <p>再看下go的环境变量</p>    <blockquote>     <p>go env</p>    </blockquote>    <pre>  GOARCH="amd64"  GOBIN="/usr/local/Cellar/go/1.5.1/bin"  GOEXE=""  GOHOSTARCH="amd64"  GOHOSTOS="darwin"  GOOS="darwin"  GOPATH="/usr/local/Cellar/go/1.5.1"  GORACE=""  GOROOT="/usr/local/Cellar/go/1.5.1/libexec"  GOTOOLDIR="/usr/local/Cellar/go/1.5.1/libexec/pkg/tool/darwin_amd64"  GO15VENDOREXPERIMENT=""  CC="clang"  GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"  CXX="clang++"  CGO_ENABLED="1"  </pre>    <p>环境变量设置成功!</p>    <p> </p>    <p>来自: <a href="/misc/goto?guid=4959670653816141029" rel="nofollow">https://segmentfault.com/a/1190000003933557</a></p>    
 本文由用户 mwrx6905 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1460594623774.html
Homebrew Google Go/Golang开发 Go