解决goland在mac m1下无法调试问题

 

背景

新电脑mac m1

goland调试抛出异常

 

 

 

异常信息

第一次异常信息

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

原因是goland版本安装错了.

下载地址:https://www.jetbrains.com/zh-cn/go/download/#section=mac

.dmg选择 Apple Silicon

 

 

 

第二次异常信息

Cannot find the Delve executable for darwin/arm64. Specify the Delve location by adding 'dlv.path=/path/to/delve' in 'Help | Edit Custom

需要配置dlv.path,步骤如下

  1. 安装 darwin/arm64 版本go , 执行:brew install go ,我电脑安装最新版: go version go1.19 darwin/arm64

  2. 安装 Apple Silicon版本的Goland ,上面已经说过,我电脑安装的是 GoLand 2022.2.2

  3. 安装delve

    1. git clone https://github.com/go-delve/delve
    2. cd delve && make install,
    3. delve会安装在 ~/go/bin/dlv  ,我本地:/Users/bj00195ml/go/bin/dlv
  4. 配置dlv,

    1. 打开Goland  Help->Edit Custom VM Options. 添加 -Ddlv.path=/Users/bj00195ml/go/bin/dlv 。bj00195ml替换成你的

    2. 打开Goland  Help->Edit Custom properties 添加 dlv.path=/Users/bj00195ml/go/bin/dlv 。bj00195ml替换成你的

  5. 重启Goland

 

20240608

由于用brew 升级了go :install go

发现goland 又不能调试了

go version 提示如下:go: cannot find GOROOT directory: /opt/homebrew/Cellar/go/1.19/libexec

 

1,官网重新下载安装 go1.22.4.darwin-arm64.pkg

2, 下载安装goland-2024.1.2-aarch64.dmg

3, open ~/.zshrc

export GOROOT=/usr/local/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN

4, brew uninstall delve

5,  brew install delve

6, cd  /opt/homebrew/Cellar/delve/1.22.1/bin

    cp dlv /Applications/GoLand.app/Contents/plugins/go-plugin/lib/dlv

 

 

 

posted @ 2022-08-20 10:05  zzhi.wang  阅读(2281)  评论(0编辑  收藏  举报