MCPcopy Create free account
hub / github.com/conventionalcommit/commitlint / toStringArr

Function toStringArr

lint/rule/rule.go:168–185  ·  view source on GitHub ↗
(arg interface{})

Source from the content-addressed store, hash-verified

166}
167
168func toStringArr(arg interface{}) ([]string, error) {
169 switch argVal := arg.(type) {
170 case []interface{}:
171 strArr := make([]string, len(argVal))
172 for index, a := range argVal {
173 strVal, ok := a.(string)
174 if !ok {
175 return nil, fmt.Errorf("expects array of string value, but got %#v", arg)
176 }
177 strArr[index] = strVal
178 }
179 return strArr, nil
180 case []string:
181 return argVal, nil
182 default:
183 return nil, fmt.Errorf("expects array of string value, but got %#v", arg)
184 }
185}

Callers 1

setStringArrArgFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected