From charlesreid1

Go Naming Conventions: https://smartystreets.com/blog/2018/10/go-naming-tutorial

Note

Exported vs Unexported names

  • Anything (variable, type, or function) that starts with a capital letter is exported, and visible outside the package.
  • Anything that does not start with a capital letter is not exported, and is visible only inside the same package.


Use single-character receiver names

package main

import "fmt"

func main() {
	new(Printer).Print(
		"Use only the first letter of a type as the receiver for its methods (oh, wait...), " + 
			"and (per tip #5) make sure the receiver is exported")
}

type Printer struct{}

func (P *Printer) Print(Message string) (N int, Err error) {
	return fmt.Println(Message)
}

Use single-letter variable names

package main

import "fmt"

func main() {
	new(Printer).Print("Use single-letter variables whenever possible")
}

type Printer struct{}

func (P *Printer) Print(M string) (N int, E error) {
	return fmt.Println(M)
}


Flags