appengine
                                
                                 appengine copied to clipboard
                                
                                    appengine copied to clipboard
                            
                            
                            
                        Debugging a go111 app
I'm starting with a very simple go111 app that builds and runs normally on a local dev server via
dev_appserver.py  app.yaml.
However, if I try to debug this app via dev_appserver.py --go_debugging=true  app.yaml, than build phase fails with
Failed to build Go application: (Executed command: go build -o /var/folders/--shortened--/_ah_exe -N -l) flag provided but not defined: -N
It seems that the debug flags passed by dev_appserver.py to go debug are wrong? If I'm not mistaken it should be -gcflags "all=-N -l" not just -N -l"?
Is there anything else I'm missing?
Hi,
I have the same issue since i migrate to go111
I also tried this:
- go build -gcflags "all=-N -l" github.com/user/project
- ./project
- dlv attach --headless=true --listen=:2345 --api-version=2 <PID>
But I get this error: panic: Metadata fetch failed for 'instance/attributes/gae_project': Get http://metadata/computeMetadata/v1/instance/attributes/gae_project: dial tcp: lookup metadata: no such host
Sorry for not seeing this bug earlier.
The good news is that this is an easy fix you can apply to your local dev_appserver instance.
Edit lines 89-91 of $(dirname $(which gcloud))/../platform/google_appengine/google/appengine/tools/devappserver2/go/gaego.py to look like:
    args = ['build']
    if self._enable_debugging:
      args.extend(['-gcflags', '"all=-N -l"'])
    args.extend(['-o', exe_name, self._main_executable_path])
Or, in diff format:
89c89
<     args = ['build', '-o', exe_name, self._main_executable_path]
---
>     args = ['build']
91c91,92
<       args.extend(['-N', '-l'])
---
>       args.extend(['-gcflags', '"all=-N -l"'])
>     args.extend(['-o', exe_name, self._main_executable_path])
I'll try to get this out in an upcoming cloud SDK release.
While using  dev_appserver.py with --go_debugging=true I got :
invalid value ""all=-N -l"" for flag -gcflags: parameter may not start with quote character "
The error disappears when modifying
/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/go/gaego.py
with
args.extend(['-gcflags', '"all=-N -l"']) ==to=> args.extend(['-gcflags', 'all=-N -l'])
There is no error with -gcflags=all=-N -l neither