MCPcopy
hub / github.com/purpleidea/mgmt / TypeMatch

Function TypeMatch

lang/funcs/simple/simple.go:228–243  ·  view source on GitHub ↗

TypeMatch accepts a list of possible type signatures that we want to check against after type unification. This helper function returns a function which is suitable for use in the scaffold check function field.

(typeList []string)

Source from the content-addressed store, hash-verified

226// against after type unification. This helper function returns a function which
227// is suitable for use in the scaffold check function field.
228func TypeMatch(typeList []string) func(*types.Type) error {
229 return func(typ *types.Type) error {
230 for _, s := range typeList {
231 t := types.NewType(s)
232 if t == nil {
233 // TODO: should we panic?
234 continue // skip
235 }
236 if unificationUtil.UnifyCmp(typ, t) == nil {
237 return nil
238 }
239 }
240 return fmt.Errorf("did not match")
241
242 }
243}
244
245// StructRegister takes an CLI args struct with optional struct tags, and
246// generates simple functions from the contained fields in the specified

Callers 4

initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
initFunction · 0.92

Calls 1

NewTypeFunction · 0.92

Tested by

no test coverage detected