Go vscode 拡張機能
コマンドパレットで
Go: Install/Update tools
command go.tools.install not found
$ echo %GOPATH%
D:/opt/GoLang/1.16.15/GOPATH
$ echo %GOENV_ROOT%
D:/opt/GoLang/1.16.15/go
go install github.com/ramya-rao-a/go-outline@latest
go install github.com/cweill/gotests/gotests@latest
go install github.com/fatih/gomodifytags@latest
go install github.com/josharian/impl@latest
go install github.com/haya14busa/goplay/cmd/goplay@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
go install golang.org/x/tools/gopls@latest
go install github.com/go-delve/delve/cmd/dlv@latest
D:\opt\GoLang\1.16.15\GOPATH\pkg\mod\honnef.co\go\tools@v0.3.2\go\ir\builder.go:36:2: //go:build comment without // +build comment
exit status 1
- .vscode\settings.json
{
"git.ignoreLimitWarning": true,
"terminal.integrated.env.windows": {
"GOPATH": "D:/opt/GoLang/1.16.15/GOPATH",
"GOENV_ROOT" : "D:/opt/GoLang/1.16.15/go",
"PATH": "${env:PATH};D:/opt/GoLang/1.16.15/go/bin;D:/opt/GoLang/1.16.15/GOPATH/bin"
},
"go.gopath": "D:/opt/GoLang/1.16.15/GOPATH",
}
色々試したけど portable 版ではダメだったので
- go1.16.15.windows-amd64.msi でインストール
その後、コントロールパネルから環境変数の "GOPATH" を "D:/opt/GoLang/1.16.15/GOPATH" に変えて
「Go: Install/Update tools」を実行したら問題なくインストールされた。。。
Go: Install/Update tools
- .vscode\settings.json
{
"terminal.integrated.env.windows": {
"GOPATH": "D:/opt/GoLang/1.16.15/GOPATH",
"GOENV_ROOT" : "D:/opt/GoLang/1.16.15/go",
"PATH": "${env:PATH};D:/opt/GoLang/1.16.15/go/bin;D:/opt/GoLang/1.16.15/GOPATH/bin"
},
}
- ごれでいけるかも。。。
{
"terminal.integrated.env.windows": {
"GOPATH": "D:/opt/GoLang/1.16.15/GOPATH",
"GOENV_ROOT" : "D:/opt/GoLang/1.16.15/go",
"PATH": "${env:PATH};D:/opt/GoLang/1.16.15/go/bin;D:/opt/GoLang/1.16.15/GOPATH/bin"
},
"go.gopath": "D:/opt/GoLang/1.16.15/GOPATH",
"go.goroot": "D:/opt/GoLang/1.16.15/go"
}
- .vscode\launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"env": {},
"args": [
"-test.v",
]
}
]
}
sample project
mkdir go-sample
cd go-sample
go mod init sample
TODO
Go言語で開発したWebアプリをローカルサーバーでデバッグする(VSCode)
Go/Gin/Vue.js/MySQLで超簡単なSPAを開発
【Go】net/httpでGetしたjsonのResponseを見る
20220706追加