先安装go环境
https://blog.csdn.net/csl12919/article/details/128372584?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22128372584%22%2C%22source%22%3A%22csl12919%22%7Dhttps://blog.csdn.net/csl12919/article/details/128372584?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22128372584%22%2C%22source%22%3A%22csl12919%22%7D
go : 无法将“go”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包
括路径,请确保路径正确,然后再试一次。
所在位置 行:1 字符: 1
+ go run main.go
+ ~~
+ CategoryInfo : ObjectNotFound: (go:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
原因分析
Go安装路径发生变化。
解决方案
在VS Code终端(PowerShell实例)中运行以下命令,使当前的PowerShell实例从计算机加载最新的路径变量。
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
vscode 安装