Incorrect string value when trying to persist data in a database

Written by
Link to Post by 

Hi, I’m trying to persist data in a database, but the insert statement returns this error :

Error 1366: Incorrect string value: 'xA9x073xEBExF3...' for column 'secret' at row 1 

This is the part of the code not working :

_, err = db.Query("INSERT INTO authentication (secret, token_id, last_login) VALUES(?, ?, ?)", secret, jwtId, datetime) fmt.Println(utf8.ValidString(secret)) 

utf8.ValidString(secret) returns false, and I don’t really understand why. secret (and jwtId) are generated with ksuid.New() from I converted this value like this : string(jwtId.Bytes()).

Any idea how to solve this problem? What’s more, I’m a bit surprised. I though all strings in Go were UTF8 encoded. Can someone explain to me what’s wrong ? Thanks.

submitted by /u/to_fl
[link] [comments]

Article Tags:
· ·
Article Categories:

Leave a Reply