Why this matters
Concise summaries and error docs improve skimmability and correctness.
The first sentence should be a standalone summary used by godoc. For functions returning error, state error conditions succinctly.
Concise summaries and error docs improve skimmability and correctness.
Side-by-side examples engineers can pattern-match during review.
// Upload stuff to s3
func Upload(ctx context.Context, p string) error { ... }// Upload uploads a file at path p to S3. Returns ErrNotFound if the file is missing.
func Upload(ctx context.Context, p string) error { ... }// Open opens the file, returning ErrPermission when not allowed.
func Open(p string) (*os.File, error) { ... }// Open file
func Open(p string) (*os.File, error) { ... }From the same buckets as this rule.
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.