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

Function LookupDefault

lang/unification/interfaces.go:112–129  ·  view source on GitHub ↗

LookupDefault attempts to return a "default" solver.

()

Source from the content-addressed store, hash-verified

110
111// LookupDefault attempts to return a "default" solver.
112func LookupDefault() (Solver, error) {
113 if len(registeredSolvers) == 0 {
114 return nil, fmt.Errorf("no registered solvers")
115 }
116 if len(registeredSolvers) == 1 {
117 for _, solver := range registeredSolvers {
118 return solver(), nil // return the first and only one
119 }
120 }
121
122 // TODO: Should we remove this empty string feature?
123 // If one was registered with no name, then use that as the default.
124 if solver, exists := registeredSolvers[""]; exists { // empty name
125 return solver(), nil
126 }
127
128 return nil, fmt.Errorf("no registered default solver")
129}

Callers 6

TestAstFunc1Function · 0.92
TestAstFunc2Function · 0.92
TestAstFunc3Function · 0.92
InitMethod · 0.92
TestUnification1Function · 0.92
CliMethod · 0.92

Calls

no outgoing calls

Tested by 4

TestAstFunc1Function · 0.74
TestAstFunc2Function · 0.74
TestAstFunc3Function · 0.74
TestUnification1Function · 0.74