Kentosh
Kentosh

Reputation: 11

How to use the Scan method

I have to use the scan method for get en store my id but the program does not want to compile.

The first time I tried:

    query := "INSERT INTO " + table + "(" + removeLastRune(columns) + ") VALUES (" + removeLastRune(values) + ") RETURNING id".scan(&id)

id".scan undefined (type untyped string has no field or method scan)

Then I apply the documentation but nothing...

query := db.QueryRow("INSERT INTO " + table + "(" + removeLastRune(columns) + ") VALUES (" + removeLastRune(values) + ") RETURNING id").scan(&id)

scan undefined (type *sql.Row has no field or method scan, but does have Scan)

An idea of ​​the problem?

Upvotes: 0

Views: 155

Answers (1)

aureliar
aureliar

Reputation: 1584

Just read the error message:

scan undefined (type *sql.Row has no field or method scan, but does have Scan)

scan is undefined but Scan is not. Replace .scan by .Scan in your second example

Upvotes: 1

Related Questions