lang: Interface sorting order
as golang does not loop over the same map/list always the same we use a helper list to sort it Signed-off-by: Toshaan Bharvani <toshaan@vantosh.com>
This commit is contained in:
committed by
James Shubin
parent
28ec7a1e54
commit
2fdf8d5dc3
@@ -20,6 +20,7 @@ package funcs // this is here, in case we allow others to register operators...
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"github.com/purpleidea/mgmt/lang/interfaces"
|
"github.com/purpleidea/mgmt/lang/interfaces"
|
||||||
"github.com/purpleidea/mgmt/lang/types"
|
"github.com/purpleidea/mgmt/lang/types"
|
||||||
@@ -376,9 +377,13 @@ func LookupOperator(operator string, size int) ([]*types.Type, error) {
|
|||||||
results := []*types.Type{}
|
results := []*types.Type{}
|
||||||
|
|
||||||
if operator == "" {
|
if operator == "" {
|
||||||
// FIXME: loop this in sorted order...
|
var keys []string
|
||||||
for _, a := range OperatorFuncs {
|
for k := range OperatorFuncs {
|
||||||
fns = append(fns, a...)
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
for _, a := range keys {
|
||||||
|
fns = append(fns, OperatorFuncs[a]...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user