Skip to content

Instantly share code, notes, and snippets.

@gdchamal
Created September 8, 2013 16:07
Show Gist options
  • Save gdchamal/6485994 to your computer and use it in GitHub Desktop.
Save gdchamal/6485994 to your computer and use it in GitHub Desktop.
// not null string
type NNstring string
func (n *NNstring) UnmarshalJSON(b []byte) (err error) {
if string(b) == "null" {
return errors.New("String can't be null")
}
return json.Unmarshal(b, (*string)(n))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment