LoginSignup
1
0

More than 1 year has passed since last update.

Go On windows

Last updated at Posted at 2022-07-01

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

Goのデバッグ環境 on VSCode

mkdir go-sample
cd go-sample
go mod init sample

TODO

Go言語で開発したWebアプリをローカルサーバーでデバッグする(VSCode)

Go/Gin/Vue.js/MySQLで超簡単なSPAを開発

クリーンアーキテクチャ

Standard Go Project Layout

go言語でクリーンアーキテクチャっぽいもの

.envを使って環境変数を読み込む(godotenv)

Golangの設計思想

【Go】net/httpでGetしたjsonのResponseを見る

20220706追加

[Go] map[string]interface{}とJSON string間の変換

Convert Map to JSON in Go

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0