Problem

While debugging code in GoLand recently, I kept encountering the following error:

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

Solution

The issue essentially means that the installed version of Delve is too old and incompatible with the current Go version.

To resolve this, update Delve. Since I’m using brew for installation, and the official documentation doesn’t provide detailed instructions for brew, we’ll 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 install a specific version:

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

By default, go install places the binary in $GOPATH/bin.

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 existing Delve and update your PATH in zsh:

1
brew uninstall delve

Edit ~/.zshrc and add:

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

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