I have a database calendar with tsrange type from postgres. It allows me to have multiple appointments and time range such as :
["2018-11-08 10:00:00","2018-11-08 10:45:00"]
How do I store this value in a Go variable ?
I tried
var tsrange []string
And when I log tsrange[0]
it is empty. What is the proper type for it ?
More code :
rows, err := db.Query("SELECT * FROM appointments")
utils.CheckErr(err)
var id int
var userID int
var tsrange []string
rows.Next()
err = rows.Scan(&id, &userID, &tsrange)
fmt.Println(tsrange[0])
When I replace var tsrange []string
with var tsrange string
the log is ["2018-11-08 10:00:00","2018-11-08 10:45:00"]
.