Not a single solution has error handling. There actually exists a very good iterator pattern in the Mongo driver mgo. The idea is that you have some function Next, and Next takes a pointer. You pass a pointer into Next, and the iterator fills that address with some data, returning a boolean indicating success. Then you just put that in a for loop to loop over the whole thing. The whole thing, with error handling, looks like this:
var v someType
for iter.Next(&v) {
// do something with v here
}
if err := iter.Err(); err != nil {
// the iterator had an error, handle that here.
}
http://godoc.org/labix.org/v2/mgo#Iter.Next