It helps prevent accidental breakages like #10, particularly with help from CI such as travis.
It integrates nicely with godoc.
Having the expected output in the example helps the reader. (Had there been expected output in main.go, I would very likely have filed a PR to fix #10 instead of filing it as an issue, but I don't know what the intention of the example is.)
When others vendor your library, go build ./... doesn't accidentally generate unneeded executables.
This has a few advantages:
main.go
, I would very likely have filed a PR to fix #10 instead of filing it as an issue, but I don't know what the intention of the example is.)go build ./...
doesn't accidentally generate unneeded executables.