Godeps/_workspace/src/gopkg.in/mgo.v2/session.go
func (q *Query) Limit(n int) *Query {
	q.m.Lock()
	switch {
	case n == 1:
		q.limit = 1
		q.op.limit = -1
	case n == math.MinInt32: // -MinInt32 == -MinInt32
		q.limit = math.MaxInt32
		q.op.limit = math.MinInt32 + 1
	case n < 0:
		q.limit = int32(-n)
		q.op.limit = int32(n)
	default:
		q.limit = int32(n)
		q.op.limit = int32(n)
	}
	q.m.Unlock()
	return q
}
func (q *Query) Limit(n int) *Query {
	q.m.Lock()
	switch {
	case n == 1:
		q.limit = 1
		q.op.limit = -1
	case n == math.MinInt32: // -MinInt32 == -MinInt32
		q.limit = math.MaxInt32
		q.op.limit = math.MinInt32 + 1
	case n < 0:
		q.limit = int32(-n)
		q.op.limit = int32(n)
	default:
		q.limit = int32(n)
		q.op.limit = int32(n)
	}
	q.m.Unlock()
	return q
}
func ( q * Query ) Limit ( n int ) * Query { q . m . Lock ( ) switch { case n == 1 : q . limit = 1 q . op . limit = - 1 case n == math . MinInt32 : // -MinInt32 == -MinInt32 q . limit = math . MaxInt32 q . op . limit = math . MinInt32 + 1 case n < 0 : q . limit = int32 ( - n ) q . op . limit = int32 ( n ) default : q . limit = int32 ( n ) q . op . limit = int32 ( n ) } q . m . Unlock ( ) return q }
// Limit restricts the maximum number of documents retrieved to n, and also
// changes the batch size to the same value.  Once n documents have been
// returned by Next, the following call will return ErrNotFound.
Limit restricts the maximum number of documents retrieved to n and also changes the batch size to the same value . Once n documents have been returned by Next the following call will return ErrNotFound .