go 仓库下载走国内代理
go env -w GOSUMDB=off
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.io
gopath多项目工作区声明区分
下面命令会在gopath目录下生成go.work
go work init
添加工作区> 编辑go.work
use (
./src/test #相对于gopath根目录的路径或者绝对路径
)
vscode补全代码提示
go get github.com/mdempsky/gocode@latest
go install github.com/mdempsky/gocode@latest
> 全局或当前工作空间的.vscode/setting.json添加
"go.useLanguageServer": true,
"[go]": {
"editor.snippetSuggestions": "none",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
}
},
"gopls": {
"usePlaceholders": true,
"completeUnimported": true,
"deepCompletion": true,
},
"files.eol": "\n",
"explorer.confirmDelete": false,
> .vscode/launch.json
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "调试",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${fileDirname}",
"args": ["serve"],
"debugAdapter": "dlv-dap"
}
]
}