// collectUserItems handles the case where multiple items pertain to the same user resource.
// User associated items are sorted by username and suffix.  Items which do not both start with
// the expected prefix *and* end with one of the expected suffixes are passed back in `rem`.
collectUserItems handles the case where multiple items pertain to the same user resource.
User associated items are sorted by username and suffix.  Items which do not both start with
the expected prefix *and* end with one of the expected suffixes are passed back in `rem`.
// collectUserItems handles the case where multiple items pertain to the same user resource . // User associated items are sorted by username and suffix . Items which do not both start with // the expected prefix * and * end with one of the expected suffixes are passed back in ` rem ` .
func collectUserItems(items []backend.Item) (users map[string]userItems, rem []backend.Item, err error) {
	users = make(map[string]userItems)
	for _, item := range items {
		key := string(item.Key)
		if !strings.HasPrefix(key, fullUsersPrefix) {
			rem = append(rem, item)
			continue
		}
		name, suffix, err := splitUsernameAndSuffix(key)
		if err != nil {
			return nil, nil, err
		}
		collector := users[name]
		if !collector.Set(suffix, item) {
			rem = append(rem, item)
			continue
		}
		users[name] = collector
	}
	return users, rem, nil
}
func collectUserItems ( items [ ] backend . Item ) ( users map [ string ] userItems , rem [ ] backend . Item , err error ) { users = make ( map [ string ] userItems ) for _ , item := range items { key := string ( item . Key ) if ! strings . HasPrefix ( key , fullUsersPrefix ) { rem = append ( rem , item ) continue } name , suffix , err := splitUsernameAndSuffix ( key ) if err != nil { return nil , nil , err } collector := users [ name ] if ! collector . Set ( suffix , item ) { rem = append ( rem , item ) continue } users [ name ] = collector } return users , rem , nil }
collectUserItems handles the case where multiple items pertain to the same user resource.
collectUserItems handles the case where multiple items pertain to the same user resource .
// suffix not recognized, output this item with the rest of the // unhandled items.