接著開啟Visual Studio Code,按下『Command + Shift + P』輸入
ext install go
在安裝extension同時,開啟Terminal並輸入下方指令將套件加入到Go
go get -u -v github.com/nsf/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v github.com/golang/lint/golint
go get -u -v github.com/lukehoban/go-outline
go get -u -v sourcegraph.com/sqs/goreturns
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v github.com/tpng/gopkgs
go get -u -v github.com/newhook/go-symbols
go get -u -v golang.org/x/tools/cmd/guru
Go的套件都加入後,請重啟Visual Studio Code,按下『Command + , 』將以下代碼貼到settings.json,並修改你的go.gopath路徑
// Place your settings in this file to overwrite the default settings
{
// Specifies the GOPATH to use when no environment variable is set.
"go.gopath": "/yourGoPath",
// Specifies the GOROOT to use when no environment variable is set.
"go.goroot": "/usr/local/go/"
}
建立一個新的Go檔案,即可看到Snippets啦!