refactor: move UnitNames to top level package

This commit is contained in:
5684185+vsariola@users.noreply.github.com
2023-10-20 01:59:30 +03:00
parent b6ec5d1a04
commit beb06727b0
4 changed files with 21 additions and 18 deletions

View File

@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"math"
"sort"
)
type (
@ -178,6 +179,18 @@ const (
Sample = iota
)
// UnitNames is a list of all the names of units, sorted
// alphabetically.
var UnitNames []string
func init() {
UnitNames = make([]string, 0, len(UnitTypes))
for k := range UnitTypes {
UnitNames = append(UnitNames, k)
}
sort.Strings(UnitNames)
}
// Ports is static map allowing quickly finding the parameters of a unit that
// can be modulated. This is populated based on the UnitTypes list during
// init(). Thus, should be immutable, but Go not supporting that, then this will