type User struct {
Email string `json:"email"`
Password string `json:"password"`
}
db, err := sql.Open("postgres", os.Getenv("DATABASE_URL"))
if err != nil {
log.Fatal(err)
}
fmt.Println("email: ", reflect.TypeOf(usr.Email)) //string
fmt.Println("salt: ", reflect.TypeOf(salt)) //[]uint8
fmt.Println("hash: ", reflect.TypeOf(hash)) //string
sql := `INSERT INTO public."Users" (email, password, salt) VALUES ($1, $2, $3)`
_, err = db.Exec(sql, usr.Email, hash, salt)
抛出错误:“pq:用于编码“UTF8”的无效字节序列:0x97”
我的表:“email”类型:TEXT,“password”类型:TEXT,“salt”类型:smallint [](认为这可能是错误,但我不确定改用什么)