What's a data structure that only allows one of a possible set of options?
I tried playing around with enum
s but they are not what I want.
package main
import "fmt"
type Event struct {
day_number Day
}
type Day int
const (
Monday Day = iota
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
)
func main() {
var r Event
r.day_number = Monday
fmt.Println(r.day_number)
// Keep this from happening.
var impossible Event
impossible.day_number = 12
fmt.Println(impossible.day_number)
}