在Mac OS上无法在VS Code中调试Go程序,但是已经具备正确的架构和HOSTOS。

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

Can't debug Go programs in VS Code on Mac OS but have the right arch and HOSTOS

问题

我看到这个问题多次,并尝试了所有可能的解决方法,但似乎问题出在其他地方。

根据该问题的每个答案中提到的内容,我安装了适用于 Apple M1 芯片的 arm64 版本的 Go。我使用的是装有 Darwin/arm64 的 MacBook。

Darwin/arm64 已经安装好了,我也可以在终端中构建和运行 Go 程序,但是使用 fn + f5 运行时出现了以下错误:

“Failed to launch: could not launch process: can not run under Rosetta, check that the installed build of Go is right for your CPU architecture”

我的 go env 配置如下:

GO111MODULE="off"
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/myName/Library/Caches/go-build"
GOENV="/Users/myName/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/myName/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/myName/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.18"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/jt/r0dd0zvj0jv0jfmdbmxxszqw0000gn/T/go-build3752056080=/tmp/go-build -gno-record-gcc-switches -fno-common"

这里有什么问题吗?我的意思是,它可以在终端中构建,所以应该可以通过某种方式解决,对吗?

英文:

I saw that question multiple times and tried all I can to solve it with the given answers, but it seems it is something else..

I installed the arm64-Version of Go as mentioned in every answer about that question. I have a Macbook with Apple M1-Chip.

Darwin/arm64 is installed, and I can also build a go program in terminal and run it through the terminal, but doing it with fn + f5 gives me that error:

"Failed to launch: could not launch process: can not run under Rosetta, check that the installed build of Go is right for your CPU architecture"

My go env Is like that:

GO111MODULE="off"
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/myName/Library/Caches/go-build"
GOENV="/Users/myName/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/myName/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/myName/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.18"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/jt/r0dd0zvj0jv0jfmdbmxxszqw0000gn/T/go-build3752056080=/tmp/go-build -gno-record-gcc-switches -fno-common"

How is that wrong? I mean, it's buildable by terminal so it should be fixable somehow, right?

答案1

得分: 1

我有一台 M1 电脑,我使用 VSC 的 insiders-edition 版本(适用于 arm 架构)。
我使用的 Go 版本是 go1.18 darwin/arm64。
我使用的 dlv 版本是:
Delve 调试器
版本:1.8.1
构建:$Id: d85f1f6b736db99a1c239c34fd4a081dcff08a3c

只有当应用程序在 Intel 上运行时,它才会抱怨 Rosetta。所以其中一个不是 arm 架构。
你之前安装过 AMD 吗?你确定已经卸载了吗?

英文:

I have an M1, a use the insiders-edition of VSC (for arm)
I have go version go1.18 darwin/arm64
I have dlv version
Delve Debugger
Version: 1.8.1
Build: $Id: d85f1f6b736db99a1c239c34fd4a081dcff08a3c

It only complains about Rosetta if the apllication runs on Intel.
So one of those if NOT arm.
Did you have a previous AMD installation? Are you sure that's gone?

huangapple
  • 本文由 发表于 2022年4月7日 18:01:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/71780117.html
匿名

发表评论

匿名网友

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

确定