Skip to content

Instantly share code, notes, and snippets.

@ryanc414
Created October 2, 2021 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanc414/debb3a2a80a0e88fda7167b4025b240f to your computer and use it in GitHub Desktop.
Save ryanc414/debb3a2a80a0e88fda7167b4025b240f to your computer and use it in GitHub Desktop.
type PrimaryColour int
const (
Red = iota
Yellow
Blue
)
func (c PrimaryColour) String() string {
switch c {
case Red:
return "Red"
case Yellow:
return "Yellow"
case Blue:
return "Blue"
default:
panic(fmt.Sprintf("unknown colour %d", int(c)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment