LoginSignup
27
13

More than 5 years have passed since last update.

Golangで`Scan error`が出た時の対応

Posted at

Golangで開発している時に
sql: Scan error on column index 1: unsupported Scan, storing driver.Value type []uint8 into type *time.Time
というエラーが出たので、対応した

解決策

DNSの末尾に?parseTime=trueを入れる

https://github.com/go-sql-driver/mysql/issues/9#issuecomment-51552649
から引用

原因

Scanするときのdeleted_atの時間の型と、structの時間の型が違うことが原因。
型をあわせる処理をmysql側でするか、golang側でする必要があるが、とりあえずmysql側でするには?parseTime=trueをつければいいらしい。

27
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
27
13