Golang json (Un)marshal custom date format
If we want to create a RESTFul API, we may need a date type field. Especially you are doing an integration API, the date format may not always be what you want. JSON serialization on GO can be annoying sometimes. In such cases, you can follow a method like that. go version 1.16 package customTypes import ( "errors" "fmt" "strings" "time" ) type JSONTime time.Time const DefaultFormat = time.RFC3339 var layouts = []string{ DefaultFormat, "2006-01-02T15:04Z", // ISO 8601 UTC "2006-01-02T15:04:05Z", // ISO 8601 UTC "2006-01-02T15:04:05....