Not able to get database data! please help

package main

import (

_ ""


type users struct {
id int
username string
password string
email string
first_name string
last_name string
created_at string
super_user bool

func main() {
db, err := sql.Open(“mysql”, “root:Megamind@1@(”)

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 returns an error, is it nil?

Also if there is an @ in the password, you might need to escape it.

Last but not least… In general it might help if you would do the following things:

  1. describe your problem, not just throw some code. Tell us what output your code produces and what you would have expected
  2. Make sure you check all possible error returns in your code.
  3. Use markdown to make your post readable

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