Delve intermittant problems with breakpoints and printing

I’m trying to use delve and I don’t even know how to describe this problem as it keeps moving around.

I’m using: go version go1.22.2 linux/amd64 and I just pulled delve off of git.

I’m having two types of problems. The first is when I try to set a break point, sometimes it works and sometimes I get Command failed: could not find statement at ... and there certainly is a statement there.

The other problem is trying to print the value of an expression. Sometimes it works and sometimes I get (unreadable could not find loclist entry at ...). I rewrite the code to make it an example I can print here and suddenly it works. I go back to the original code and it still works. So I move on to the next problem, try and put in a break statement or print something out and it’s the same issue.

I’m new to go and one thing I’ve noticed is the build process is just a huge mystery and because things have changed so much and the documentation is so opaque, lots of examples I see just don’t work as described. So I just fumbled around until I found something that worked. The hello world program is great, but add some packages and none of that works. I ended up using replace in go.mod because I’d rather not put all my files on git right now. Is that a mistake? But back to this issue of delve, I have no idea if I’m compiling the right way.

I would really like to give a more concrete example but that’s not working. Any ideas?

My apologies, but I’m a bit frustrated. Thanks for your patience.

That worked, thank you so much. One small correction, though: it’s -gcflags=all=“-N -l” (the first " was in the wrong place. Anyway, that’s the first time I’ve seen anything close to a man page. So that was a big help.