News for hackers. Stuff that matters.
Re:Go is boring, and that’s fantastic by bbatha on Sunday July 05, 2020 @01:37PM (#23740372)
This happens all of the time for enums in structs especially during (de)serialization and returning a zero value and an error. func DeserializeState(raw []byte) (State, error) { type Foo struct { State state `json:"state"` Data map[string]string `json:"data"` } f := Foo{} err := json.Unmarshal(&foo, raw) if err != nil { return ???, err }

   }
   s := DeserializeState([]byte(`{"data": {"key": "value"}}`)
   fmt.Println(s) // prints 0 oops

There are no comments on this comment yet.