Godeps/_workspace/src/gopkg.in/mgo.v2/session.go
func (iter *Iter) All(result interface{}) error {
	resultv := reflect.ValueOf(result)
	if resultv.Kind() != reflect.Ptr || resultv.Elem().Kind() != reflect.Slice {
		panic("result argument must be a slice address")
	}
	slicev := resultv.Elem()
	slicev = slicev.Slice(0, slicev.Cap())
	elemt := slicev.Type().Elem()
	i := 0
	for {
		if slicev.Len() == i {
			elemp := reflect.New(elemt)
			if !iter.Next(elemp.Interface()) {
				break
			}
			slicev = reflect.Append(slicev, elemp.Elem())
			slicev = slicev.Slice(0, slicev.Cap())
		} else {
			if !iter.Next(slicev.Index(i).Addr().Interface()) {
				break
			}
		}
		i++
	}
	resultv.Elem().Set(slicev.Slice(0, i))
	return iter.Close()
}
func (iter *Iter) All(result interface{}) error {
	resultv := reflect.ValueOf(result)
	if resultv.Kind() != reflect.Ptr || resultv.Elem().Kind() != reflect.Slice {
		panic("result argument must be a slice address")
	}
	slicev := resultv.Elem()
	slicev = slicev.Slice(0, slicev.Cap())
	elemt := slicev.Type().Elem()
	i := 0
	for {
		if slicev.Len() == i {
			elemp := reflect.New(elemt)
			if !iter.Next(elemp.Interface()) {
				break
			}
			slicev = reflect.Append(slicev, elemp.Elem())
			slicev = slicev.Slice(0, slicev.Cap())
		} else {
			if !iter.Next(slicev.Index(i).Addr().Interface()) {
				break
			}
		}
		i++
	}
	resultv.Elem().Set(slicev.Slice(0, i))
	return iter.Close()
}
func ( iter * Iter ) All ( result interface { } ) error { resultv := reflect . ValueOf ( result ) if resultv . Kind ( ) != reflect . Ptr || resultv . Elem ( ) . Kind ( ) != reflect . Slice { panic ( " " ) } slicev := resultv . Elem ( ) slicev = slicev . Slice ( 0 , slicev . Cap ( ) ) elemt := slicev . Type ( ) . Elem ( ) i := 0 for { if slicev . Len ( ) == i { elemp := reflect . New ( elemt ) if ! iter . Next ( elemp . Interface ( ) ) { break } slicev = reflect . Append ( slicev , elemp . Elem ( ) ) slicev = slicev . Slice ( 0 , slicev . Cap ( ) ) } else { if ! iter . Next ( slicev . Index ( i ) . Addr ( ) . Interface ( ) ) { break } } i ++ } resultv . Elem ( ) . Set ( slicev . Slice ( 0 , i ) ) return iter . Close ( ) }
// All retrieves all documents from the result set into the provided slice
// and closes the iterator.
//
// The result argument must necessarily be the address for a slice. The slice
// may be nil or previously allocated.
//
// WARNING: Obviously, All must not be used with result sets that may be
// potentially large, since it may consume all memory until the system
// crashes. Consider building the query with a Limit clause to ensure the
// result size is bounded.
//
// For instance:
//
//    var result []struct{ Value int }
//    iter := collection.Find(nil).Limit(100).Iter()
//    err := iter.All(&result)
//    if err != nil {
//        return err
//    }
//
All retrieves all documents from the result set into the provided slice and closes the iterator . The result argument must necessarily be the address for a slice . The slice may be nil or previously allocated . WARNING : Obviously All must not be used with result sets that may be potentially large since it may consume all memory until the system crashes . Consider building the query with a Limit clause to ensure the result size is bounded . For instance : var result [] struct { Value int } iter : = collection . Find ( nil ) . Limit ( 100 ) . Iter () err : = iter . All ( &result ) if err ! = nil { return err }