vscode golang插件安装(代码提示,跳转)
go语言环境搭建,大家可自行百度,或者可以点击:go语言环境搭建(linux)
首先,需要安装好 go 插件,插件市场搜索go
,选一个即可安装。
然后,需要安装 go 的工具包。在 vscode 中,输入快捷键:command(ctrl) + shift + p
,在弹出的窗口中,输入:go:install/Update Tools
,回车后,选择所有插件(勾一下全选),点击确认,进行安装(设置GOPROXY)。
Installing 18 tools at /Users/liaojinlong/Workspace/CPChain/chain/bin
gocode
gopkgs
go-outline
go-symbols
guru
gorename
dlv
gocode-gomod
godef
goimports
golint
gopls
gotests
gomodifytags
impl
fillstruct
goplay
godoctor
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/go-delve/delve/cmd/dlv SUCCEEDED
Installing github.com/stamblerre/gocode SUCCEEDED
Installing github.com/rogpeppe/godef SUCCEEDED
Installing golang.org/x/tools/cmd/goimports SUCCEEDED
Installing golang.org/x/lint/golint SUCCEEDED
Installing golang.org/x/tools/cmd/gopls 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
Installing github.com/godoctor/godoctor SUCCEEDED
接下来,在项目的 settings.json
文件中添加配置:
"go.goroot": "D:\\Go", "go.gopath": "D:\\gopath", //第三方库代码提示 "go.inferGopath": true, "go.formatTool": "goreturns", //自动完成未导入的包 "go.autocompleteUnimportedPackages": true, "go.gocodePackageLookupMode": "go", "go.gotoSymbol.includeImports": true, "go.docsTool": "gogetdoc", "go.useCodeSnippetsOnFunctionSuggest": true, "go.useCodeSnippetsOnFunctionSuggestWithoutType": true,
"go.useLanguageServer": true,
"[go]": { "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.organizeImports": true, }, // Optional: Disable snippets, as they conflict with completion ranking. "editor.snippetSuggestions": "none", },"[go.mod]": { "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.organizeImports": true, }, },"go.trace.server": "verbose", "gopls": { // Add parameter placeholders when completing a function. "usePlaceholders": false, // If true, enable additional analyses with staticcheck. // Warning: This will significantly increase memory usage. "staticcheck": false, },"go.languageServerFlags": [ "-remote=auto", "-logfile=auto", "-debug=:0", "-rpc.trace", ],
windows配置git-bash终端
"terminal.integrated.profiles.windows": { "PowerShell -NoProfile": { "source": "PowerShell", "args": [ "-NoProfile" ] }, "Git-Bash": { "path": "C:\\Program Files\\Git\\bin\\bash.exe", "args": [] } }, "terminal.integrated.defaultProfile.windows": "Git-Bash"
基础配置
"editor.fontSize": 14, // Fira Code字体好看 又发现字体也好看 Maple Mono "editor.fontFamily": "'Maple Mono','Fira Code Retina','Fira Code Medium', Consolas, 'Courier New', monospace", "editor.fontLigatures": true, // "workbench.iconTheme": "material-icon-theme", "workbench.iconTheme": "vscode-icons", "workbench.colorTheme": "Monokai Pro", "workbench.startupEditor": "none", "window.zoomLevel": 1, "files.autoSave": "afterDelay", "git.autofetch": true, "editor.lineHeight":24
关于字体推荐见我另一篇文章:字体推荐(编程、写代码、系统)
评论:
2024-09-25 15:29