GoLand IDE: Debug program initiated by shell script (Kubernetes local cluster)

1/22/2020

I'm a beginner to Kubernetes, and I tried to understand the source code by debugging from GoLand IDE. Starting a cluster with the provided hack/local-up-cluster.sh script works fine, but I cannot debug in GoLand.

I've tried to edit Run -> EditConfigurations-> +Shell Script with the script path as hack/local-up-cluster.sh, the script could run successfully but it won't stop at any break point.

Can someone please help me on how to set the IDE to debug the code initiated by a shell script?

-- Ruogu Zhang
debugging
goland
kubernetes

1 Answer

1/23/2020

If you don't use the IDE to launch the process, then you can use the Run | Attach to process feature to attach the IDE debugger to an existing project.

Make sure that the compiled application has the optimizations turned off, if you are using Go 1.10+ the compiler flag is -gcflags="all=-N -l".

-- dlsniper
Source: StackOverflow