Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in documentation (http://jmoiron.github.io/sqlx/) Alternate Scan Types #58

Closed
frankbb opened this issue May 1, 2014 · 4 comments

Comments

@frankbb
Copy link

frankbb commented May 1, 2014

When i try the second alternate scan type i get an error. I created a test program directly from your documentation. Am i doing something wrong?

package main

import (
    "github.com/jmoiron/sqlx"
)

func main () {
    rows, err := db.Queryx("SELECT * FROM place")
    for rows.Next() {
        results := map[string]interface{}
        err = rows.MapScan(results)
    }
}

I get the following error:
./test.go:10: syntax error: unexpected semicolon or newline, expecting {

@freeeve
Copy link

freeeve commented May 1, 2014

You need another {} for results := map[string]interface{}{}, in order to create an empty instance of the map[string]interface{}. Yeah looks like the docs are wrong.

@jmoiron
Copy link
Owner

jmoiron commented May 1, 2014

Whoops. Where in the docs is that?

@freeeve
Copy link

freeeve commented May 1, 2014

In the "alternate scan types" section.

@jmoiron
Copy link
Owner

jmoiron commented May 1, 2014

Found and fixed. You can either of these:

results := make(map[string]interface{})
// or
results := map[string]interface{}{}

Updated the docs to use the first because it looks less confusing.

@jmoiron jmoiron closed this as completed May 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants