// generated by jsonenums -type=WeekDay; DO NOT EDIT package main import ( "encoding/json" "fmt" ) func (r WeekDay) String() string { switch r { case Monday: return "Monday" case Tuesday: return "Tuesday" case Wednesday: return "Wednesday" case Thursday: return "Thursday" case Friday: return "Friday" case Saturday: return "Saturday" case Sunday: return "Sunday" default: return "unknown WeekDay" } } func (r WeekDay) MarshalJSON() ([]byte, error) { return json.Marshal(r.String()) } func (r *WeekDay) UnmarshalJSON(data []byte) error { var s string if err := json.Unmarshal(data, &s); err != nil { return fmt.Errorf("WeekDay should be a string, got %s", data) } switch s { case "Monday": *r = Monday case "Tuesday": *r = Tuesday case "Wednesday": *r = Wednesday case "Thursday": *r = Thursday case "Friday": *r = Friday case "Saturday": *r = Saturday case "Sunday": *r = Sunday default: return fmt.Errorf("invalid WeekDay %q", s) } return nil }