When to use Examples?

Hi all,

When do you use examples ? Do you combine them with godoc, can you share more details if you have been using them.

Personally I am experimenting with documenting code, and some examples appearing in godoc could be valuable, but am not sure if this is the standard.

Examples being included in the godoc is standard:

See also:

Next, take a look at this example:

And then take a look at the corresponding code:


For me, examples are often all I need to get started with a module, and thus they are extremely useful. I can get a quick example and then discover the other surface area of the module Iā€™m using via intellisense / spelunking directly through the source. But I suppose it depends on the module.

1 Like