Go常见问题(一)Visual Studio Code 无法识别 go 指令

问题现象

PS D:\...> go env
go : 无法将“go”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
所在位置 行:1 字符: 1
+ go env
+ ~~
    + CategoryInfo          : ObjectNotFound: (go:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

原因分析

Go安装路径发生变化。

解决方案

在VS Code终端(PowerShell实例)中运行以下命令,使当前的PowerShell实例从计算机加载最新的路径变量。

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

你可能感兴趣的:(Go常见问题(一)Visual Studio Code 无法识别 go 指令)