Skip to content

Coding Guidelines

Logan Saso edited this page Nov 30, 2023 · 7 revisions

General Guidelines

  • Prefer code that is easy to read and understand to code that is "elegant" or clever.
  • When in doubt, leave a comment.
  • If you change code near a comment, check to make sure the comment and the code still agree.
  • Tests are good. If you are removing or disabling a test, there had better be a good reason for it.
  • Avoid lots of nested conditions. Three is probably the most you should ever use. Prefer early returns if possible.

Concrete Guidelines

  • When constructing or parsing URLs, use golang's url library.
  • Boolean variables should be named isThing, hasThing, etc.
  • When creating/copying new slices, arrays, use make([]T, 0, len(expectedSize)) with append for maximum safety, don't use direct index assignment.
Clone this wiki locally