Golang conventions

From wikinotes
Revision as of 21:24, 23 May 2022 by Will (talk | contribs) (Created page with "= Naming = <blockquote> == Casing == <blockquote> <syntaxhighlight lang="go"> func DoThing() { ... } // exported functions are PascalCase func doThing() { ... } // regular f...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Naming

Casing

func DoThing() { ... }  // exported functions are PascalCase
func doThing() { ... }  // regular functions are camelCase

Interfaces

// interfaces should end in 'er' (or similar)
Writer, Reader, Formatter, Notifier, Flusher, Stringer

// implementations of interfaces should drop the 'er'
Write, Read, Format, Notify, Flush, String

Syntax

Semicolons

Go uses semicolons as line-endings, but prefers that the semicolon is implied automatically.