How to run go run program in debug mode
There is no specific built in debug mode as such. One approach is to have a var debug bool
that you set from a command line flag or similar and then use to control log output. It can also be a constant that you instead control via a build tag, in which case the debug code doesn’t exist at all in the production binary.
There is some debug information that can be extracted from the runtime - garbage collection statistics for example. See the runtime documentation around GODEBUG
for that. Also the stack trace that you get for each goroutine on a crash or QUIT signal is very nice.
1 Like
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.