query.go
func Single(iter Enumerable) (retval interface{}, err error) {
	done := make(chan struct{})
	defer close(done)

	err = errNoElements

	firstPass := true
	for entry := range iter.Enumerate(done) {
		if firstPass {
			retval = entry
			err = nil
		} else {
			retval = nil
			err = errMultipleElements
			break
		}
		firstPass = false
	}
	return
}
func Single(iter Enumerable) (retval interface{}, err error) {
	done := make(chan struct{})
	defer close(done)

	err = errNoElements

	firstPass := true
	for entry := range iter.Enumerate(done) {
		if firstPass {
			retval = entry
			err = nil
		} else {
			retval = nil
			err = errMultipleElements
			break
		}
		firstPass = false
	}
	return
}
func Single ( iter Enumerable ) ( retval interface { } , err error ) { done := make ( chan struct { } ) defer close ( done ) err = errNoElements firstPass := true for entry := range iter . Enumerate ( done ) { if firstPass { retval = entry err = nil } else { retval = nil err = errMultipleElements break } firstPass = false } return }
// Single retreives the only element from a list, or returns nil and an error.
Single retreives the only element from a list or returns nil and an error .