Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
术语';go';无法识别为cmdlet、函数、脚本文件或可操作程序的名称_Go_Visual Studio Code - Fatal编程技术网

术语';go';无法识别为cmdlet、函数、脚本文件或可操作程序的名称

术语';go';无法识别为cmdlet、函数、脚本文件或可操作程序的名称,go,visual-studio-code,Go,Visual Studio Code,跑步之后 go run main.go 我得到这个错误 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. 已解决:转到vi

跑步之后

go run main.go
我得到这个错误

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.

已解决:转到visual studio代码(假定已安装)ctrl+shift+p打开命令窗口类型

Go:当前GOPATH

这将为您提供一个路径,创建一个名为GOPATH的系统环境变量,并将该路径添加到该变量中

确保系统环境变量设置为:

GOPATH(在我的例子中)设置为C:\Users[username]\go

GOROOT设置为C:\go\

IDE是Visual Studio代码

$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")

将代码写入终端并运行它。一种解决问题的方法。

如果您解决了自己的问题,请将解决方案放在答案中,而不是问题中。在Windows灌输中,Go MSI将GOPATH安装为用户变量,而不是系统变量。感谢您的修复。I get-Go::术语“Go:”不被识别为cmdlet、函数、脚本文件或可操作程序的名称。需要重新启动VSCode。这只能工作一次,不能永久工作!