duannaoye0732 2019-04-26 18:46 采纳率: 100%
浏览 3526
已采纳

go:术语“ go”未被识别为cmdlet,函数,脚本文件或可运行程序的名称

这个问题已经有人回答 了,但是对我来说还是不起作用。这可能是因为我用的是新的 VS 代码版本。我的步骤:

  1. 已安装插件
  1. 在命令窗口ctrl+Shift+P中,输入Go:install/Update Tools并安装所有17个软件包。

  2. 但是我得到了一个错误,这是目录结构

  1. 来自cmd的Go env输出:
D:\Personal\Learning\GoLang\Project-1>go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users
og1\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
og1\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
  1. 我的PATH环境变量: C:\Go\bin;

  2. 我的VS代码设置.json条目:

    "go.autocompleteUnimportedPackages": true,
    "go.gopath": "D:\\Personal\\Learning\\GoLang\\Project-1\\",
    "go.goroot": "C:\\Go\\",

我哪里出错了?

  • 写回答

2条回答 默认 最新

  • dongsicheng5262 2019-04-28 07:25
    关注

    please try to run the following command in the vscode terminal (which is an instance of powershell):

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

    It will make the current powershell instance to load the latest PATH variable from the machine.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密
  • ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴
  • ¥15 下列c语言代码为何输出了多余的空格