// reduceDuplicates eliminates duplicate MarshalIdentifier from input and calls `method` on every unique MarshalIdentifier
reduceDuplicates eliminates duplicate MarshalIdentifier from input and calls `method` on every unique MarshalIdentifier
// reduceDuplicates eliminates duplicate MarshalIdentifier from input and calls ` method ` on every unique MarshalIdentifier
func reduceDuplicates(
	input []MarshalIdentifier,
	information ServerInformation,
	method func(MarshalIdentifier, ServerInformation) (map[string]interface{}, error),
) (
	[]map[string]interface{},
	error,
) {
	var (
		alreadyIncluded  = make(map[string]map[string]bool)
		includedElements []map[string]interface{}
	)
	for _, referencedStruct := range input {
		if referencedStruct == nil {
			continue
		}
		structType := getStructType(referencedStruct)
		if alreadyIncluded[structType] == nil {
			alreadyIncluded[structType] = make(map[string]bool)
		}
		if !alreadyIncluded[structType][referencedStruct.GetID()] {
			marshalled, err := method(referencedStruct, information)
			if err != nil {
				return includedElements, err
			}
			includedElements = append(includedElements, marshalled)
			alreadyIncluded[structType][referencedStruct.GetID()] = true
		}
	}
	return includedElements, nil
}
func reduceDuplicates ( input [ ] MarshalIdentifier , information ServerInformation , method func ( MarshalIdentifier , ServerInformation ) ( map [ string ] interface { } , error ) , ) ( [ ] map [ string ] interface { } , error , ) { var ( alreadyIncluded = make ( map [ string ] map [ string ] bool ) includedElements [ ] map [ string ] interface { } ) for _ , referencedStruct := range input { if referencedStruct == nil { continue } structType := getStructType ( referencedStruct ) if alreadyIncluded [ structType ] == nil { alreadyIncluded [ structType ] = make ( map [ string ] bool ) } if ! alreadyIncluded [ structType ] [ referencedStruct . GetID ( ) ] { marshalled , err := method ( referencedStruct , information ) if err != nil { return includedElements , err } includedElements = append ( includedElements , marshalled ) alreadyIncluded [ structType ] [ referencedStruct . GetID ( ) ] = true } } return includedElements , nil }
reduceDuplicates eliminates duplicate MarshalIdentifier from input and calls `method` on every unique MarshalIdentifier
reduceDuplicates eliminates duplicate MarshalIdentifier from input and calls ` method ` on every unique MarshalIdentifier