Adding examples to godoc is pretty trivial but no one really talks about how multi-line output works. It’s also trivial but I thought I’d give an example.

According to the godoc tricks to add the output for an example method you just add // Output: ... at the end of your example code. The problem is that no one really mentions how you could do nicely formatted multi-line output like for a json object or something.

It’s pretty intuitive:

// Output: {
//     "key": "value"
// }

Here it is on the godoc website: