// RequestMethod defines http request method
type RequestMethod int
// Request methods
const (
	GET RequestMethod = iota
	POST
)
func (rm RequestMethod) String() string {
	switch rm {
	case GET:
		return "GET"
	case POST:
		return "POST"
	default:
		return "Unknown"
	}
}
- まずint型の別名としてtypeを設定する
 - constのブロックの中でiotaを呼ぶと上から連番で0,1,2...と振ってくれる
 
- iotaの応用は https://splice.com/blog/iota-elegant-constants-golang/ が詳しい
 
- そのままだとPrintした時に、0とか1とか数字が出てしまうので、作成したtypeに対してString()メソッドを用意しておくと良い
 
- これはダックタイピングのGo的にはStringerインターフェースを実装したことになるhttps://golang.org/pkg/fmt/#Stringer
 
- (おまけ) 大文字始まりのものはExportされるので、GoDoc用に上のような形でコメントを入れておく。そうしないと、golintでWarningが出る。