summaryrefslogtreecommitdiffstats
path: root/models/unit.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/unit.go')
-rw-r--r--models/unit.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/models/unit.go b/models/unit.go
index 1d26359528..9619232cf4 100644
--- a/models/unit.go
+++ b/models/unit.go
@@ -4,6 +4,10 @@
package models
+import (
+ "strings"
+)
+
// UnitType is Unit's Type
type UnitType int
@@ -137,3 +141,16 @@ var (
UnitTypeExternalWiki: UnitExternalWiki,
}
)
+
+// FindUnitTypes give the unit key name and return unit
+func FindUnitTypes(nameKeys ...string) (res []UnitType) {
+ for _, key := range nameKeys {
+ for t, u := range Units {
+ if strings.EqualFold(key, u.NameKey) {
+ res = append(res, t)
+ break
+ }
+ }
+ }
+ return
+}