Problem

When debugging code in Goland recently, the following error is always reported:

1
WARNING: undefined behavior - version of Delve is too old for Go version 1.19.3 (maximum supported version 1.18)

Solution

The problem probably means that the Delve version is too low and cannot meet the current Golang version

Update delve. Since I use brew to install it here, the default official website installation document does not explain brew too much, and there is no upgrade method, so we can just install it directly.

1
2
3
git clone https://github.com/go-delve/delve
cd delve
go install github.com/go-delve/delve/cmd/dlv

Or according to the specified version:

1
2
3
4
# Install the latest release
go install github.com/go-delve/delve/cmd/dlv@latest
# Install 1.20.1
go install github.com/go-delve/delve/cmd/dlv@1.20.1

By default, go install is installed under GOPATH

1
2
3
4
5
6
# go env GOPATH
/Users/wanzi/go
# ./go/bin/dlv version
Delve Debugger
Version: 1.20.1
Build: $Id: 96e65b6c615845d42e0e31d903f6475b0e4ece6e $

Uninstall the default delve and update the PATH in the current zsh:

1
brew uninstall delve

Update vim ~/.zshrc as follows:

1
export PATH="${PATH}:${HOME}/.krew/bin/:$HOME/go/bin"

Reference: https://github.com/go-delve/delve/tree/master/Documentation/installation