繁体   English   中英

GoLand on Apple Silicon 无法调试golang项目

[英]GoLand on Apple Silicon can not debug golang project

编辑 2021-01-28:这整个问题现在已经过时,因为 GoLand 2020.3.2 今天发布了,它包括一个工作钻研。 正如发行说明所指出的,不要忘记删除您可能所做的更改。

我正在尝试在 Apple Silicon 上使用 GoLand 调试 golang 项目,但它不起作用; 错误如下:

API server listening at: [::]:62619
debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-1200.0.44 for x86_64.
error: failed to launch process /Library/Developer/CommandLineTools/Library/PrivateFrameworks/LLDB.framework/Versions/A/Resources/debugserver: (os/kern) invalid argument
Exiting.
could not launch process: stub exited while waiting for connection: exit status 0

编辑 2021-01-28:这整个问题(和这个答案)现在已经过时了,因为今天发布了GoLand 2020.3.2,它包括一个有效的研究。 正如发行说明指出的那样,不要忘记删除您可能所做的更改。

用户 14892075 的回答和主要受https 的启发://www.reddit.com/r/golang/comments/kqgxel/debugging_wcli_and_goland_works_on_apple_m1/这里的技术直到正式发布 Goland 和 dlv

  1. 为 arm64 安装 golang。 如果你有 brew 的 arm64 版本,最简单的方法是brew install golang ,它现在运行良好。 这个时候你会得到 golang v1.16-beta1。
  2. 安装 Apple Silicon 版本的 Goland
  3. 查看钻研。 PR已经合并了, git clone https://github.com/go-delve/delve ,然后用cd delve && make install编译,就会把delve放到~/go/bin/dlv
  4. 打开 Goland 和 go 到 Help->Edit Custom VM Options。 在那里添加一行-Ddlv.path=/Users/rfay/go/bin/dlv (将用户名从 rfay 更改为您的,或将路径编辑为您构建的 dlv 的完整路径)。
  5. 重启戈兰

GoLand使用Delve作为调试器。 Delve 尚不支持 Apple Silicon。

Jetbrains 和 Delve 有 bug 票来跟踪这一点。 我建议您观看这些门票以获取更新:

  1. https://youtrack.jetbrains.com/issue/GO-10235
  2. https://github.com/go-delve/delve/issues/2246

但是在 Go 版本 1.16 之前,不要指望“稳定”和官方的东西,它有官方的 Apple Silicon 支持。 目前,发布计划于 2 月发布。

Go 支持 Apple Silicon 可能是 Delve 在 Apple Silicon 上工作的先决条件,因为通过 Rosetta 进行调试似乎不可行。 所以 Delve 需要使用 Go 1.16 编译才能在 Apple Silicon 上原生工作。

因此,Apple Silicon 对 Delve 的官方支持可能不会在 2021 年 2 月之前发生

我已经安装了 go(darwin) 版本,它是 1.16 和之前的 delve。 我尝试设置环境(“env”:{“GOOS”:“darwin”,“GOARCH”:“arm64”})并更新软件包,但这些都不起作用。

我通过以下步骤解决了 VSCode 中的问题:

  1. Go:选择 go 环境
  2. 选择或获取go1.17.3/更高版本
  3. 按 F5 - 它会警告您不安装或直接安装 >Go: Install/Update Tools - 然后 select delve。

我的 Apple M1 Pro 也有同样的问题,我已经安装了 Apple Silicon Goland( 2021.3.4 apple silicon version )和 Golang( 1.18 drawin/arm64 )。

因为我从一台旧机器( 2019 Mac Pro )迁移到一台新机器( 2021 Mac M1 )。 我的/Applications/Xcode.app/Contents/Developer是这个问题的老领导。

尝试:

// remove CommandLineTools
$ sudo rm -rf /Library/Developer/CommandLineTools

// reinstall, about 20min
$ xcode-select --install

然后一切就OK了!

它现在可以工作了。参见: https://github.com/oxisto/delve/tree/darwin-arm64-lldb它还没有合并到 master 分支;'去构建'它并替换 Goland dlv 插件,然后 Degbugger 工作。

我有golang 1.16.6并且仍然面临与此错误消息相同的问题: Use go sdk for darwin/arm64

我的解决方案是添加以下 ENV

GOOS=darwin, GOARCH=arm64

在此处输入图像描述

我今天在Goland 2022.3上遇到了同样的问题。 您需要为 mac M1 使用正确的 go 版本。 然后更新GOARCH可以提供帮助。

我通过转到Preferences -> Go -> Build Tags & Vendoring修复了这个错误,然后在Arch上,将值更新为arm64

安装拱门

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM