I need to get the length of *sql.Rows
before I begin my Next() loop to get the values out. One way is to create a slice of rows by looping over Next() twice, getting the count, and then looping over that new slice to pull the values out, but that seems really inefficient so I'm hoping there is a better way to do this.
Looking at the docs, I see no mention of a Count function or Length function that I can use: https://golang.org/pkg/database/sql/#Rows
Looking at the Go code, I can't see anything in the struct that would help me (although I could be missing something, so would appreciate a second pair of eyes here): https://github.com/golang/go/blob/master/src/database/sql/sql.go#L1714
Surely there is some way to do this that is better than just looping over Next() twice?
I realize I could do a separate count query as well, or even include a count(*) in my other select, but I'd rather avoid this too. This is for a Go ORM project, and I don't want to overcomplicate the select statement, and I'd rather avoid tampering with their built-up request as much as possible.
Thanks.