user/group.go
func (*Group) lookUp(line string, f field, value interface{}) interface{} {
	_field := f.(groupField)
	allField := strings.Split(line, ":")
	arrayField := make(map[int][]string)
	intField := make(map[int]int)

	arrayField[3] = strings.Split(allField[3], ",")

	// Check integers
	var err error
	if intField[2], err = strconv.Atoi(allField[2]); err != nil {
		panic(atoiError{_GROUP_FILE, line, "GID"})
	}

	// Check fields
	var isField bool
	if G_NAME&_field != 0 && allField[0] == value.(string) {
		isField = true
	} else if G_PASSWD&_field != 0 && allField[1] == value.(string) {
		isField = true
	} else if G_GID&_field != 0 && intField[2] == value.(int) {
		isField = true
	} else if G_MEMBER&_field != 0 && checkGroup(arrayField[3], value.(string)) {
		isField = true
	} else if G_ALL&_field != 0 {
		isField = true
	}

	if isField {
		return &Group{
			Name:     allField[0],
			password: allField[1],
			GID:      intField[2],
			UserList: arrayField[3],
		}
	}
	return nil
}
func (*Group) lookUp(line string, f field, value interface{}) interface{} {
	_field := f.(groupField)
	allField := strings.Split(line, ":")
	arrayField := make(map[int][]string)
	intField := make(map[int]int)

	arrayField[3] = strings.Split(allField[3], ",")

	// Check integers
	var err error
	if intField[2], err = strconv.Atoi(allField[2]); err != nil {
		panic(atoiError{_GROUP_FILE, line, "GID"})
	}

	// Check fields
	var isField bool
	if G_NAME&_field != 0 && allField[0] == value.(string) {
		isField = true
	} else if G_PASSWD&_field != 0 && allField[1] == value.(string) {
		isField = true
	} else if G_GID&_field != 0 && intField[2] == value.(int) {
		isField = true
	} else if G_MEMBER&_field != 0 && checkGroup(arrayField[3], value.(string)) {
		isField = true
	} else if G_ALL&_field != 0 {
		isField = true
	}

	if isField {
		return &Group{
			Name:     allField[0],
			password: allField[1],
			GID:      intField[2],
			UserList: arrayField[3],
		}
	}
	return nil
}
func ( * Group ) lookUp ( line string , f field , value interface { } ) interface { } { _field := f . ( groupField ) allField := strings . Split ( line , " " ) arrayField := make ( map [ int ] [ ] string ) intField := make ( map [ int ] int ) arrayField [ 3 ] = strings . Split ( allField [ 3 ] , " " ) // Check integers var err error if intField [ 2 ] , err = strconv . Atoi ( allField [ 2 ] ) ; err != nil { panic ( atoiError { _GROUP_FILE , line , " " } ) } // Check fields var isField bool if G_NAME & _field != 0 && allField [ 0 ] == value . ( string ) { isField = true } else if G_PASSWD & _field != 0 && allField [ 1 ] == value . ( string ) { isField = true } else if G_GID & _field != 0 && intField [ 2 ] == value . ( int ) { isField = true } else if G_MEMBER & _field != 0 && checkGroup ( arrayField [ 3 ] , value . ( string ) ) { isField = true } else if G_ALL & _field != 0 { isField = true } if isField { return & Group { Name : allField [ 0 ] , password : allField [ 1 ] , GID : intField [ 2 ] , UserList : arrayField [ 3 ] , } } return nil }
// == Lookup
//
// lookUp parses the group line searching a value into the field.
// Returns nil if it is not found.
== Lookup lookUp parses the group line searching a value into the field . Returns nil if it is not found .