Created
July 19, 2017 18:02
-
-
Save xandout/abe5a663edc6d78d92957aa83d6dde31 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// defer rows.Close() | |
// colNames, err := rows.Columns() | |
// if err != nil { | |
// log.Fatal(err) | |
// } | |
// cols := make([]interface{}, len(colNames)) | |
// colPtrs := make([]interface{}, len(colNames)) | |
// for i := 0; i < len(colNames); i++ { | |
// colPtrs[i] = &cols[i] | |
// } | |
// for rows.Next() { | |
// var myMap = make(map[string]interface{}) | |
// err = rows.Scan(colPtrs...) | |
// if err != nil { | |
// log.Fatal(err) | |
// } | |
// for i, col := range cols { | |
// myMap[colNames[i]] = col | |
// } | |
// // Do something with the map | |
// for key, val := range myMap { | |
// fmt.Println("Key:", key, "Value Type:", reflect.TypeOf(val)) | |
// } | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment