簡體   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