func expandComponents()

in getdeps/main.go [147:175]


func expandComponents(componentString string) ([]string, error) {
	// if no component is specified, assume all supported components.
	if componentString == "" {
		return supportedComponents, nil
	}
	components := strings.Split(componentString, ",")
	if len(components) == 0 {
		return supportedComponents, nil
	}
	cMap := make(map[string]struct{}, 0)
	for _, c := range components {
		found := false
		c = strings.ToLower(c)
		for _, sc := range supportedComponents {
			if c == sc {
				found = true
			}
		}
		if found == false {
			return nil, fmt.Errorf("unsupported component '%s'", c)
		}
		cMap[c] = struct{}{}
	}
	ret := make([]string, 0, len(cMap))
	for k := range cMap {
		ret = append(ret, k)
	}
	return ret, nil
}