Compile error with Sql.NullXXXX

I just trying to get data from a datasbe table with sime fields null. This data will be convert to json after read.
I created 3 vars to be fill with table data

var (
			item              customerInformationOutput
			state             sql.NullString
			confirmationDelay sql.NullInt64
			linkedTo          sql.NullString
		)

But golang compiler show the lines where sql.NullXXX is used marked as error with message

services\getcustomerinformation.go:122:25: sql.NullString undefined (type string has no field or method NullString)
services\getcustomerinformation.go:123:25: sql.NullInt64 undefined (type string has no field or method NullInt64)
services\getcustomerinformation.go:124:25: sql.NullString undefined (type string has no field or method NullString)

I have the corresponding import “database/sql” and in another source I have the same usage without problem…

Any idea what I have to check ?

TIA,
Yamil

2 Likes

You have declared a string variable called “sql” in the same scope. This hides the package “sql”.

3 Likes

Hi
Yes, I solved in my mind way to home…
It is a clear sign i need vacations!!!
Thanks a lot!!!

3 Likes

Good to see you solved your problem. Please, mark the question as answered.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.