I'm currently attempting to fetch a time.Time object from my SQL database and convert the retrieved value to a formatted string that looks like so:
TIME_FORMAT := "%Y-%m-%dT%H:%M:%S"
This is the format I have used to do the same thing in Python, but I know it is not correct for go. I have already grabbed the value from the DB, and now just need to format it. Please note I have defined ccc.Ia_date as interface{} type because it is possible that this value in the DB could be null. Here is a clip of my code:
fmt.Println(reflect.TypeOf(ccc.Ia_date)) //gives me time.Time
t := ccc.Ia_date //which prints as: 2016-11-16 21:06:39 +0000 +0000
fmt.Println(t.Format())
and I get the following error:
t.Format undefined (type interface {} is interface with no methods)
Am I missing an import? Or is this just not possible using interface types? If so, what alternatives do I have to accept null values from the DB? (I have already seen the related answer to Golang: convert time.Time to string - I tried that solution but I'm not grabbing time.Now and that's the only difference I see)