This commit is contained in:
2026-06-05 22:35:28 +02:00
parent 88623f55df
commit 51d3a734e8
21 changed files with 2613 additions and 153 deletions
+21 -1
View File
@@ -1,6 +1,9 @@
package dxcc
import "strings"
import (
"sort"
"strings"
)
// The dxccByName table itself lives in dxcc_names_gen.go (generated by joining
// cty.dat to the authoritative ARRL/ADIF entity list). cty.dat doesn't carry
@@ -55,6 +58,23 @@ func NameForDXCC(n int) string {
return strings.Title(name) //nolint:staticcheck // ASCII entity names
}
// EntityNumberName pairs a DXCC entity number with its display name.
type EntityNumberName struct {
Num int
Name string
}
// AllEntities returns every known DXCC entity (number + display name), sorted by
// number. Used to seed the DXCC award's reference list.
func AllEntities() []EntityNumberName {
out := make([]EntityNumberName, 0, len(nameByDXCC))
for num := range nameByDXCC {
out = append(out, EntityNumberName{Num: num, Name: NameForDXCC(num)})
}
sort.Slice(out, func(i, j int) bool { return out[i].Num < out[j].Num })
return out
}
// dxccByCanon is dxccByName re-keyed by the canonical entity form, built once.
var dxccByCanon = func() map[string]int {
m := make(map[string]int, len(dxccByName))