Skip to content

How to use RowToMap with a custom map definition #2249

Answered by jackc
jflambert asked this question in Q&A
Discussion options

You must be logged in to vote

RowToMap is designed to represent each row as a key-value pair. It's not what you are looking for.

What you are really looking for is a version of CollectRows that collects into a map instead of a slice. The code for CollectRows is pretty simple, you can either copy and change that or use rows.Next() and rows.Scan() directly.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jflambert
Comment options

Answer selected by jflambert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants