
Windows 中“go: The term 'go' is not recognize”错误的疑难解答
当尝试执行“go run main.go”时,您可能会遇到以下错误:
1 | 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.
|
登录后复制
要解决此问题,您需要将 Go 安装目录添加到环境变量中。操作方法如下:
1 | $env :Path = [System.Environment]::GetEnvironmentVariable( "Path" , "Machine" )
|
登录后复制
此命令检索“Path”环境变量的当前值。接下来,将 Go 安装目录的路径附加到该值。例如,如果 Go 安装在“C:Go”中,请使用以下命令:
1 | $env :Path += ";C:\Go\bin"
|
登录后复制
最后,通过运行保存更改:
1 | [System.Environment]::SetEnvironmentVariable( "Path" , $env :Path, "Machine" )
|
登录后复制
完成这些步骤后,重新启动终端并尝试再次运行“go run main.go”。该错误应该已解决。
以上是为什么我无法运行'go run main.go”?的详细内容。更多信息请关注PHP中文网其他相关文章!