Skip to content

Instantly share code, notes, and snippets.

@akhenakh
Last active November 19, 2018 14:29
Show Gist options
  • Save akhenakh/1cba30bacff5ff503858f80379e1845d to your computer and use it in GitHub Desktop.
Save akhenakh/1cba30bacff5ff503858f80379e1845d to your computer and use it in GitHub Desktop.
go-spew pretty printer for Golang
$ go get -u github.com/davecgh/go-spew/spew

In VS Code, go to Preferences > User Snippets > Go and add go.json sd snippet.

type sd to use the snippet

package main

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

func main() {
	spew.Dump([]byte{'g', 'o', 'l', 'a', 'n', 'g'}) // DEBUG
}

Enjoy your debug

([]uint8) (len=6 cap=6) {
 00000000  67 6f 6c 61 6e 67                                 |golang|
}
{
"sd": {
"prefix": "sd",
"body": "spew.Dump($1) // DEBUG",
"description": "Pretty-print dump"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment