user/user.go
func parseUser(row string) (*User, error) {
	fields := strings.Split(row, ":")
	if len(fields) != 7 {
		return nil, rowError{_USER_FILE, row}
	}

	uid, err := strconv.Atoi(fields[2])
	if err != nil {
		return nil, atoiError{_USER_FILE, row, "UID"}
	}
	gid, err := strconv.Atoi(fields[3])
	if err != nil {
		return nil, atoiError{_USER_FILE, row, "GID"}
	}

	return &User{
		Name:     fields[0],
		password: fields[1],
		UID:      uid,
		GID:      gid,
		Gecos:    fields[4],
		Dir:      fields[5],
		Shell:    fields[6],
	}, nil
}
func parseUser(row string) (*User, error) {
	fields := strings.Split(row, ":")
	if len(fields) != 7 {
		return nil, rowError{_USER_FILE, row}
	}

	uid, err := strconv.Atoi(fields[2])
	if err != nil {
		return nil, atoiError{_USER_FILE, row, "UID"}
	}
	gid, err := strconv.Atoi(fields[3])
	if err != nil {
		return nil, atoiError{_USER_FILE, row, "GID"}
	}

	return &User{
		Name:     fields[0],
		password: fields[1],
		UID:      uid,
		GID:      gid,
		Gecos:    fields[4],
		Dir:      fields[5],
		Shell:    fields[6],
	}, nil
}
func parseUser ( row string ) ( * User , error ) { fields := strings . Split ( row , " " ) if len ( fields ) != 7 { return nil , rowError { _USER_FILE , row } } uid , err := strconv . Atoi ( fields [ 2 ] ) if err != nil { return nil , atoiError { _USER_FILE , row , " " } } gid , err := strconv . Atoi ( fields [ 3 ] ) if err != nil { return nil , atoiError { _USER_FILE , row , " " } } return & User { Name : fields [ 0 ] , password : fields [ 1 ] , UID : uid , GID : gid , Gecos : fields [ 4 ] , Dir : fields [ 5 ] , Shell : fields [ 6 ] , } , nil }
// parseUser parses the row of an user.
parseUser parses the row of an user .