go : 术语 'go' 未被识别为 cmdlet、函数、脚本文件或可运行程序的名称
go : The term 'go' is not recognized as the name of a cmdlet, function, script file, or operable program
此问题已得到解答 ,但就我而言,这不起作用。这可能是因为新的 VS 代码版本。我的步数:
- 已安装插件
在命令 window ctrl+shift+P
中,输入 Go: Install/Update Tools
并安装所有 17 个软件包
但是我收到了错误。这是目录结构:
- 我的
go env
来自 cmd
的输出:
D:\Personal\Learning\GoLang\Project-1>go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\rog1\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Go\bin;D:\Personal\Learning\GoLang\Project-1;
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\rog1\AppData\Local\Temp\go-build020393970=/tmp/go-build -gno-record-gcc-switches
go : The term 'go' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ go env
+~~
- CategoryInfo : ObjectNotFound: (go:String) [], CommandNotFoundException
- FullyQualifiedErrorId : CommandNotFoundException
我的 PATH
环境变量:C:\Go\bin;
我的VS Code
setting.json
条目:
"go.autocompleteUnimportedPackages": true,
"go.gopath": "D:\Personal\Learning\GoLang\Project-1\",
"go.goroot": "C:\Go\",
我错过了什么?
请在 vscode 终端(它是 powershell 的一个实例)中尝试 运行 以下命令:
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
它会让当前的powershell实例从机器上加载最新的PATH变量。
有时当您安装 Go
和 Visual studio code
并尝试 运行 代码而不重新启动 OS 时会发生这种情况。
分辨率
----------------
- 尝试重新启动 OS。
- 打开 Visual studio 代码并尝试 运行 重新输入代码。
此问题已得到解答
- 已安装插件
在命令 window
ctrl+shift+P
中,输入Go: Install/Update Tools
并安装所有 17 个软件包但是我收到了错误。这是目录结构:
- 我的
go env
来自cmd
的输出:
D:\Personal\Learning\GoLang\Project-1>go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\rog1\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Go\bin;D:\Personal\Learning\GoLang\Project-1;
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\rog1\AppData\Local\Temp\go-build020393970=/tmp/go-build -gno-record-gcc-switches
go : The term 'go' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1 + go env
+~~
- CategoryInfo : ObjectNotFound: (go:String) [], CommandNotFoundException
- FullyQualifiedErrorId : CommandNotFoundException
我的
PATH
环境变量:C:\Go\bin;
我的
VS Code
setting.json
条目:
"go.autocompleteUnimportedPackages": true,
"go.gopath": "D:\Personal\Learning\GoLang\Project-1\",
"go.goroot": "C:\Go\",
我错过了什么?
请在 vscode 终端(它是 powershell 的一个实例)中尝试 运行 以下命令:
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
它会让当前的powershell实例从机器上加载最新的PATH变量。
有时当您安装 Go
和 Visual studio code
并尝试 运行 代码而不重新启动 OS 时会发生这种情况。
分辨率
----------------
- 尝试重新启动 OS。
- 打开 Visual studio 代码并尝试 运行 重新输入代码。