unsupported Scan, storing driver.Value type []uint8 into type *time.Time

In my case, I had a similar problem but for my particular usecase, it was a struct with a select which didn't work, since I only needed to select data, then I proceeded to simply:

change the data type from time.Time to string

This solved my problem, and I was able to get the data from the database. So perhaps it is not the best solution, but this is what worked for me.

Mr Karlom's solution also worked for me, this is just an alternative method.


In my case, changing to

db, err := sql.Open("mysql", "root:@/?parseTime=true")

resolved problem.


Alright, I found the solution, thanks this answer. The problem goes by adding ?parseTime=true to the db mapper. Like this:

db, err := sqlx.Connect("mysql", "myuser:mypass@tcp(127.0.0.1:3306)/mydb?parseTime=true")

Tags:

Mysql

Go

Sqlx