Godeps/_workspace/src/gopkg.in/mgo.v2/session.go
func fixMROut(out interface{}) interface{} {
	outv := reflect.ValueOf(out)
	if outv.Kind() != reflect.Map || outv.Type().Key() != reflect.TypeOf("") {
		return out
	}
	outs := make(bson.D, outv.Len())

	outTypeIndex := -1
	for i, k := range outv.MapKeys() {
		ks := k.String()
		outs[i].Name = ks
		outs[i].Value = outv.MapIndex(k).Interface()
		switch ks {
		case "normal", "replace", "merge", "reduce", "inline":
			outTypeIndex = i
		}
	}
	if outTypeIndex > 0 {
		outs[0], outs[outTypeIndex] = outs[outTypeIndex], outs[0]
	}
	return outs
}
func fixMROut(out interface{}) interface{} {
	outv := reflect.ValueOf(out)
	if outv.Kind() != reflect.Map || outv.Type().Key() != reflect.TypeOf("") {
		return out
	}
	outs := make(bson.D, outv.Len())

	outTypeIndex := -1
	for i, k := range outv.MapKeys() {
		ks := k.String()
		outs[i].Name = ks
		outs[i].Value = outv.MapIndex(k).Interface()
		switch ks {
		case "normal", "replace", "merge", "reduce", "inline":
			outTypeIndex = i
		}
	}
	if outTypeIndex > 0 {
		outs[0], outs[outTypeIndex] = outs[outTypeIndex], outs[0]
	}
	return outs
}
func fixMROut ( out interface { } ) interface { } { outv := reflect . ValueOf ( out ) if outv . Kind ( ) != reflect . Map || outv . Type ( ) . Key ( ) != reflect . TypeOf ( " " ) { return out } outs := make ( bson . D , outv . Len ( ) ) outTypeIndex := - 1 for i , k := range outv . MapKeys ( ) { ks := k . String ( ) outs [ i ] . Name = ks outs [ i ] . Value = outv . MapIndex ( k ) . Interface ( ) switch ks { case " " , " " , " " , " " , " " : outTypeIndex = i } } if outTypeIndex > 0 { outs [ 0 ] , outs [ outTypeIndex ] = outs [ outTypeIndex ] , outs [ 0 ] } return outs }
// The "out" option in the MapReduce command must be ordered. This was
// found after the implementation was accepting maps for a long time,
// so rather than breaking the API, we'll fix the order if necessary.
// Details about the order requirement may be seen in MongoDB's code:
//
//     http://goo.gl/L8jwJX
//
The out option in the MapReduce command must be ordered . This was found after the implementation was accepting maps for a long time so rather than breaking the API we ll fix the order if necessary . Details about the order requirement may be seen in MongoDB s code : http : // goo . gl / L8jwJX