if err != nil {
log.Fatalln("Couldn't connect to the database")
}
var user users
row := db.QueryRow("select password from users where username=$1", "someone")
row.Scan(&user.password)
fmt.Println(user)
Hey I’m sorry for not describing the problem correctly and thanks for coming up for help.
I wanted to get hashed password of used but I’m trying to print whether the user name is printing correctly or not, while printing I’m getting zero value of the structure
Eg {0 false}
I’m not sure what you mean when you talk about the password…
Anyway, have you checked the return value of row.Scan?
Also, you can only use some basic types or those implementing Scanner as arguments to row.Scan, users is neither one of the basic types, nor does it implement any methods, so its not a Scanner as well.
So this is probably the reason why you see you zero-values.
Also your query is just selecting the password column, and you try to assign it to a users struct. I’d assume password contains a string…