Question: In python it's a simple `db.query("SELECT id,login,password FROM Users")` and return list `[(1,'root','password'), (2,'toor','password')]`. I can simple iterate it

```
for user in response:print("id: %s, login: %s, password: %s", %(user[0],user[1],user[2]))

```

But in Golang I can't find revelant example for simple way to do this.

I understand that a python has dynamic typing, golang is static. So I'm looking for an answer, maybe some libraries provide such functionality? Hacks? Thanks for answers!

Answer: 
You need something like this, but there may be a problem if you are using complex mysql's data types like enum, set and etc.

```
var (
    result    [][]string
    container []string
    pointers  []interface{}
)

rows, err := db.Query("SELECT id, login, password FROM Users")

if err != nil {
    panic(err.Error())
}

cols, err := rows.Columns()

if err != nil {
    panic(err.Error())
}

length := len(cols)

for rows.Next() {
    pointers = make([]interface{}, length)
    container = make([]string, length)

    for i := range pointers {
        pointers[i] = &container[i]
    }

    err = rows.Scan(pointers...)

    if err != nil {
        panic(err.Error())
    }

    result = append(result, container)
}

```

Then you can loop over results and print it using fmt package.
An awesome library that nicely extends the go standard lib sql interface is [sqlx](https://github.com/jmoiron/sqlx)

Using this lib, you can do something similar to your example in python:

```
db, err := sqlx.Connect("postgres", "user=foo dbname=bar sslmode=disable")
if err != nil {    
    log.Fatalln(err)
}
users := []User{}
db.Select(&users, "SELECT id,login,password FROM Users")
//iterate through the users slice

```