I am trying to invoke the Go debugger dlv so that the relevant executable is not optimized, so far without success. Here is what I am doing:
I am working on a project that consists of several Go source code files, across several directories. I cd into the directory where the Go lives that contains main(). In that directory I invoke
dlv debug --build-flags="-gcflags='-N -l'" . -- <options>
where just represents options that need to run my application.
After doing this, dlv hangs for a while, apparently building the executable, and when it is done I end up at the dlv command line. I can get the application going all right, and it runs as it should.
Now after setting a break point at some function (any function), when breaking into it dlv prints out (among other things)
Warning: debugging optimized function
I have tried variations on the dlv command above (e.g. removing the ‘=’ signs, etc.) to no avail. My code is built from a Makefile, but I understand that dlv ignores makefiles. At any rate, I changed things at the Makefile in an effort to build without optimizations, again without any success, as far as dlv is concerned. This is all with Go 1.9.2 under Linux.
Any ideas on how to proceed?