Skip to content

Instantly share code, notes, and snippets.

@anta40
Last active October 22, 2019 09:04
Show Gist options
  • Save anta40/10aff56a7414d438b7cffe59203467aa to your computer and use it in GitHub Desktop.
Save anta40/10aff56a7414d438b7cffe59203467aa to your computer and use it in GitHub Desktop.
type NullTime struct {
sql.NullString
}
func (nt *NullTime) MarshalJSON() ([]byte, error) {
if !nt.NullString.Valid {
return []byte("null"), nil
}
t, _ := time.Parse(time.RFC3339, nt.String)
return json.Marshal(t.Format("15:04:05"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment