You debug Go programs by attaching the Delve debugger to your binary or running it directly with dlv.
dlv debug ./main.go
Inside the Delve REPL, use break main to set a breakpoint, continue to run until that point, and next or step to execute line by line. Use print variableName to inspect values and list to view source code context.