Skip to content

Instantly share code, notes, and snippets.

@podhmo
Last active May 1, 2020 18:21
Show Gist options
  • Save podhmo/33ae2bc632815360d6e47020f3ffeb39 to your computer and use it in GitHub Desktop.
Save podhmo/33ae2bc632815360d6e47020f3ffeb39 to your computer and use it in GitHub Desktop.
package main
import "fmt"
type Op uint8
const (
OpAdd Op = iota + 1
OpSub
OpMul
)
var (
_ops = [...]string{"", "Add", "Sub", "Mul"}
)
func (v Op) String() string {
return _ops[v]
}
func main() {
fmt.Println(OpAdd)
fmt.Println(OpAdd == OpAdd, OpAdd == OpMul)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment