MCPcopy Create free account
hub / github.com/ddev/ddev / InterfaceSliceToStringSlice

Function InterfaceSliceToStringSlice

pkg/util/utils.go:350–365  ·  view source on GitHub ↗

InterfaceSliceToStringSlice converts a slice of interfaces to a slice of strings

(input any)

Source from the content-addressed store, hash-verified

348
349// InterfaceSliceToStringSlice converts a slice of interfaces to a slice of strings
350func InterfaceSliceToStringSlice(input any) ([]string, error) {
351 switch v := input.(type) {
352 case []any:
353 raw := make([]string, len(v))
354 for i := range v {
355 if s, ok := v[i].(string); ok {
356 raw[i] = s
357 } else {
358 return nil, fmt.Errorf("%v is not a string", v[i])
359 }
360 }
361 return raw, nil
362 default:
363 return nil, fmt.Errorf("unexpected type: %T", input)
364 }
365}
366
367// SliceToUniqueSlice processes a slice of string to make sure there are no duplicates
368func SliceToUniqueSlice(inSlice *[]string) []string {

Callers 1

NewTaskFunction · 0.92

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected