Comments

  • Document all exported types, functions, and constants with Go doc comments.
  • Ensure that the comments convey the meaning behind the code, not just the what.
  • All comments must end with a full stop, including inline comments and multi-line comments.
  • Within function bodies, only keep comments that explain why something is done, not what is done. The code itself should be clear enough to show what it does.
  • Keep high-level comments that explain the flow or purpose of a section (e.g., “Try loading template file first”, “Fallback to static markdown file”).
  • Remove obvious comments that just restate the code (e.g., “Load base template” before a LoadTemplate() call).

Example:

1// Generator handles file scaffolding operations for WebKit projects.
2type Generator interface {
3	// Bytes writes raw bytes to a file with optional configuration.
4	//
5	// Returns an error when  the file failed to write.
6	Bytes(path string, data []byte, opts ...Option) error
7}
Last modified: 27/10/2025 2022-2025 ©ainsley.dev, All rights reserved.