VSCode 必須安裝以下插件:
首先你必須安裝 Golang 插件,然后再給 Go 安裝工具包。
在 VS Code 中,使用快捷鍵: command+shift+P
,然后鍵入: go:install/update tools
,將所有 16 個插件都勾選上,然后點擊 OK 即開始安裝。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
Installing 16 tools at /Users/maiyang/develop/goworkspace//bin gocode gopkgs go-outline go-symbols guru gorename dlv godef godoc goreturns golint gotests gomodifytags impl fillstruct goplay Installing github.com/mdempsky/gocode SUCCEEDED Installing github.com/uudashr/gopkgs/cmd/gopkgs SUCCEEDED Installing github.com/ramya-rao-a/go-outline SUCCEEDED Installing github.com/acroca/go-symbols SUCCEEDED Installing golang.org/x/tools/cmd/guru SUCCEEDED Installing golang.org/x/tools/cmd/gorename SUCCEEDED Installing github.com/derekparker/delve/cmd/dlv SUCCEEDED Installing github.com/rogpeppe/godef SUCCEEDED Installing golang.org/x/tools/cmd/godoc SUCCEEDED Installing github.com/sqs/goreturns SUCCEEDED Installing github.com/golang/lint/golint SUCCEEDED Installing github.com/cweill/gotests/... SUCCEEDED Installing github.com/fatih/gomodifytags SUCCEEDED Installing github.com/josharian/impl SUCCEEDED Installing github.com/davidrjenni/reftools/cmd/fillstruct SUCCEEDED Installing github.com/haya14busa/goplay/cmd/goplay SUCCEEDED All tools successfully installed. You're ready to Go :). |
修改默認配置的方法:
在 Preferences -> Setting
然后輸入 go,然后選擇 setting.json
,填入你想要修改的配置
自動完成未導入的包。
"go.autocompleteUnimportedPackages": true,
VSCode 的一些插件需要配置代理,才能夠正常安裝。(配合VPN一起使用)
"http.proxy": "192.168.0.100:1087",
如果你遇到使用標準包可以出現(xiàn)代碼提示,但是使用自己的包或者第三方庫無法出現(xiàn)代碼提示,你可以查看一下你的配置項。
"go.inferGopath": true,
如果引用的包使用了 ( . “aa.com/text”) 那這個text包下的函數(shù)也無法跳轉進去,這是為什么?
修改 "go.docsTool
" 為 gogetdoc ,默認是 godoc。
"go.docsTool": "gogetdoc",
其他
- 當我們在使用 import 功能的時候,如果無法通過 lint 檢查,則不會執(zhí)行自動 import。
- 如果你需要自動 import 的前提是你必須把要導入的包的函數(shù)寫完整。
附帶我的 settings.json
1
2
3
4
5
6
7
8
9
10
11
|
{ "go.goroot": "", "go.gopath": "", "go.inferGopath": true, "go.autocompleteUnimportedPackages": true, "go.gocodePackageLookupMode": "go", "go.gotoSymbol.includeImports": true, "go.useCodeSnippetsOnFunctionSuggest": true, "go.useCodeSnippetsOnFunctionSuggestWithoutType": true, "go.docsTool": "gogetdoc", } |
參考文章: https://maiyang.me/post/2018-09-14-tips-vscode/
總結
到此這篇關于VSCode必裝Go語言以下插件的文章就介紹到這了,更多相關VSCode go語言插件內容請搜索服務器之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持服務器之家!
原文鏈接:https://studygolang.com/articles/27577