I'm working with an external API that will sometimes shorten the returned timestamp if the last values are zero.
layout := "2006-01-02T15:04:05.000"
opened, err := time.Parse(layout, externallyFormattedTimestamp)
if err != nil {
fmt.Println("something went wrong parsing the timestamp")
fmt.Println(err.Error())
}
If the returned externallyFormattedTimestamp is 2018-11-05T06:19:59.827
, this will parse without issue.
But if the time returned ends with zeros, it'll be shortened like 2018-11-05T06:19:59.8
instead of 2018-11-05T06:19:59.800
, and break. Do I need to manually append zeros to the string before parsing, or is there something I missed built into Go that will handle this for me?