Hi,
I tried to find an answer on the web couldn’t find anything so asking here.
The line stmt.Exec(u.Name) causes Error 1406: Data too long for column 'name' at row 1. The name field in MySQL DB is set to Varchar 11. If I change it to text in DB it does work but that’s a hack. Any way of solving this issue.
Thanks
type User struct {
	ID uint16
	Name string
}
func Insert(u *User) (int64, error) {
	stmt, err := r.db.Prepare("INSERT INTO users (name) VALUES (?)")
	if err != nil {
		return 0, err
	}
	res, err := stmt.Exec(u.Name) // u.Name is set to 'Hello World' so it is short!
	if err != nil {
		return 0, err
	}
	id, err := res.LastInsertId()
	if err != nil {
		return 0, err
	}
	// By the way, should I call `defer` or `close` on anything?
	return id, nil
}