S.O.S. Visual Studio无法运行go文件,出现错误信息:go:没有名为”asm”的工具。

huangapple go评论96阅读模式
英文:

S.O.S. Visual Studio can't run go file, go: no such tool "asm"

问题

我一直在使用Visual Studio Code学习Go语言,一直没有遇到问题,直到今天早上我尝试创建一个mod文件时出现了问题。现在,每当我尝试运行我的代码或重新安装Go工具时,都会遇到以下错误:
go: 没有找到工具"asm"

我希望能得到详细的帮助(记住我是个新手),告诉我如何解决这个问题。我已经尝试卸载和重新安装Visual Studio Code、Go和Visual Studio Code的Go扩展,但都没有成功。

我看到有一个关于类似问题的帖子,但是它没有给出任何可理解/详细的答案。

如果有帮助的话,这是"go tool"和"go env"的输出。

在终端中运行"go tool"的结果是:

addr2line
buildid
cgo
compile
cover
dist
doc
fix
go_bootstrap
link
nm
objdump
pack
pprof
test2json
trace
vet

运行"go env"的结果是:

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\cbh2132\AppData\Local\go-build
set GOENV=C:\Users\cbh2132\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\cbh2132\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\cbh2132\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.18.2
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=
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\cbh2132\AppData\Local\Temp\go-build1320767531=/tmp/go-build -gno-record-gcc-switches
英文:

I've been learning Go in Visual Studio Code and wasn't having any problems until I tried to create a mod file for the first time this morning. Now, whenever I try to run my code or reinstall Go tools, I get stopped by this error:
go: no such tool "asm"

I would appreciate detailed help (remember I'm a novice) on how to resolve this. I've tried uninstalling and reinstalling Visual Studio Code, GO, and the GO extension in Visual Studio Code to no avail.

I've seen one other thread about a problem like this but it didn't give any understandable/detailed answers.

In case it helps here is the output from "go tool" and "go env".

Running "go tool" in my terminal gives:

addr2line
buildid
cgo
compile
cover
dist
doc
fix
go_bootstrap
link
nm
objdump
pack
pprof
test2json
trace
vet

Running "go env" gives:

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\cbh2132\AppData\Local\go-build
set GOENV=C:\Users\cbh2132\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\cbh2132\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\cbh2132\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.18.2
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=
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\cbh2132\AppData\Local\Temp\go-build1320767531=/tmp/go-build -gno-record-gcc-switches

答案1

得分: 1

我成功解决了这个问题!所以,即使我卸载了Golang...我仍然有一个名为"go"的文件,里面包含了所有的包工具(例如asm.exe等),它在我的文档文件夹中。在卸载go之后,我不得不删除那个文件,然后重新安装go以及在Visual Studio Code中安装go工具。现在看起来又可以正常工作了!这真是一种解脱。

英文:

I managed to solve this problem! So, even when I uninstalled Golang...I still had a file called "go" with all the package tools (e.g. asm.exe, etc) that was in my documents folder. I had to delete that file after uninstalling go and then reinstall go as well as the go tools in Visual Studio Code. Now it seems to be working again! This is such a relief.

huangapple
  • 本文由 发表于 2022年5月15日 01:33:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/72242562.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定