這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。
- 安裝Golang (略)
- 安裝VS Code (略)
- 設定環境變數 (source ~/.bash_profile)
export GOROOT='/usr/local/go'export GOARCH='amd64'export GOOS='darwin'export GOPATH='/Users/your_name/gopath'export PATH='/bin:/sbin:/usr/bin:/usr/local/bin:/usr/local/go/bin'
4. VSCode 安裝擴充(略)
5. 執行如下指令碼 (執行指令碼前,就確保環境變數生效 source ~/.bash_profile)
#!/bin/bashBASEDIR="$GOPATH/src/golang.org/x"echo "BASEDIR >> $BASEDIR"if [ ! -d $BASEDIR ];then mkdir -p $BASEDIR echo "create $BASEDIR"ficd $BASEDIRif [ ! -d "$BASEDIR/tools" ];then git clone https://github.com/golang/toolselse cd $BASEDIR/tools git pullfigo install golang.org/x/tools/cmd/gurugo install golang.org/x/tools/cmd/guru/serialgo install golang.org/x/tools/cmd/gorenamego install golang.org/x/tools/cmd/goimportsgo install golang.org/x/tools/go/loadergo install golang.org/x/tools/go/buildutilgo install golang.org/x/tools/go/ast/astutilgo install golang.org/x/tools/go/gcexportdatago install golang.org/x/tools/go/gcimporter15go install golang.org/x/tools/go/ast/astutilgo install golang.org/x/tools/go/types/typeutilgo install golang.org/x/tools/refactor/satisfygo install golang.org/x/tools/refactor/renamego install golang.org/x/tools/refactor/importgraphgo install golang.org/x/tools/importsgo get -v github.com/nsf/gocodego get -v github.com/rogpeppe/godefgo get -v github.com/golang/lint/golintgo get -v github.com/lukehoban/go-outlinego get -v sourcegraph.com/sqs/goreturnsgo get -v golang.org/x/tools/cmd/gorenamego get -v github.com/tpng/gopkgsgo get -v github.com/newhook/go-symbolsgo get -v golang.org/x/tools/cmd/guru
6. 開啟VSCode,開始 Go!Go!Go!吧