Debugging in Go
Back to current version Restore this version

IDEs#

Visual Studio Code#

https://github.com/Microsoft/vscode-go/wiki/Debugging-Go-code-using-VS-Code

GoLand#

Caviats#

Debugging in Go is currently flaky as Delve fails to get the proper objects.

Tools#

There are several tools to help though.

Spew#

https://github.com/davecgh/go-spew

Add this import line to the file you're working in:

import "github.com/davecgh/go-spew/spew"

To dump a variable with full newlines, indentation, type, and pointer information use Dump, Fdump, or Sdump:

spew.Dump(myVar1, myVar2, ...)
spew.Fdump(someWriter, myVar1, myVar2, ...)
str := spew.Sdump(myVar1, myVar2, ...)

CategoryComputing.Lang.Go