Use sql.RawBytes to get an error:
The error appears 锛歷alues := make([]sql.RawBytes, len(c))
sql := `select * from table`
if rows, err := td.db.Query(sql); err == nil {
if c, er := rows.Columns(); er == nil {
values := make([]sql.RawBytes, len(c))
scanArgs := make([]interface{}, len(values))
for i := range values {
scanArgs[i] = &values[i]
}
for rows.Next() {
if er = rows.Scan(scanArgs...); er == nil {
for i, cc := range c {
fmt.Println(scanArgs[i])
}
}
}
}
}
sql.RawBytes undefined (type string has no field or method RawBytes)
Driver version (or git SHA):
1.3
Go version: run go version in your console
go1.9
Server version: E.g. MySQL 5.6, MariaDB 10.0.20
MySQL5.5
Server OS: E.g. Debian 8.1 (Jessie), Windows 10
CentOS6
you masked the database/sql package here: sql := `select * from table
sql is then a string, not the package. Rename the string e.g. to query and it will work
馃憣
3Q 3Q
Most helpful comment
you masked the
database/sqlpackage here:sql := `select * from tablesqlis then a string, not the package. Rename the string e.g. toqueryand it will work