使用goland ide工具,本地调试运行main.go报错,无法断点调试
使用goland ide工具,本地调试运行main.go报错,无法断点调试。
但是命令行(go run main.go)可以运行。
GOROOT=/usr/local/go #gosetup
GOPATH=/Users/xxx/go #gosetup
/usr/local/go/bin/go build -o /Users/xxx/Library/Caches/JetBrains/GoLand2025.1/tmp/GoLand/___go_build_go_course_expiration -gcflags all=-N -l go-course-expiration #gosetup
/Applications/GoLand.app/Contents/plugins/go-plugin/lib/dlv/macarm/dlv --listen=198.18.4.15:56788 --headless=true --api-version=2 --check-go-version=false --only-same-user=false exec /Users/xxx/Library/Caches/JetBrains/GoLand2025.1/tmp/GoLand/___go_build_go_course_expiration -- #gosetup
couldn't start listener: listen tcp 198.18.4.15:56788: bind: can't assign requested addressDebugger finished with the exit code 1
原因是本地host绑定缺失。

检查是否有对localhost进行绑定IP地址127.0.0.1
我在gpt工具问了个遍,也没给我指出问题所在,特此记录一下,希望可以帮助到你。
忘记了什么时候SwitchHosts把localhost给禁用了。

如果你也遇到这个错误,不妨检查下看。
