私は、アクセス権のリストを持っている:構造体フィールドをリストからの値にするにはどうすればいいですか?
const (
Everyone = 0
Owner = 1
Administrator = 2
)
とルートを表す構造体:
type Route struct {
Name string
Method string
Pattern string
HandlerFunc http.HandlerFunc
AccessLevel uint64
}
私はRoute
のAccessLevel
フィールド値を上から一つだけ、それらのconstのこと、構造体を制限するにはどうすればよいですか?
[Golang:定数型を作成し、Typeの値を制限する]の複製(http://stackoverflow.com/questions/37385007/golang-creating-a-constant-type-and-restricting -the-types-values/37386119#37386119)。 – icza