VSCode Golang 環境搭建 (mac os)

來源:互聯網
上載者:User
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。
  1. 安裝Golang (略)
  2. 安裝VS Code (略)
  3. 設定環境變數 (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!吧

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.