Documentation
ยถ
Index ยถ
- Constants
- Variables
- func ToUcWord(s string) string
- type Client
- func (c *Client) Close() error
- func (c *Client) FetchAndStore(ctx context.Context)
- func (c *Client) FetchAndStoreData(ctx context.Context)
- func (c *Client) GetDxccInfo(ctx context.Context, callsign string, lookupDate *time.Time) (*DxccInfo, error)
- func (c *Client) GetEntities() map[int]DxccEntity
- func (c *Client) GetException(call string) (*DxccInfo, bool)
- func (c *Client) GetExceptions() map[string]DxccException
- func (c *Client) GetHTTPClient() *http.Client
- func (c *Client) GetLastDownloadTime(ctx context.Context) (time.Time, error)
- func (c *Client) GetPrefix(prefix string) (*DxccInfo, bool)
- func (c *Client) GetPrefixes() map[string]DxccPrefix
- func (c *Client) LoadMaps(ctx context.Context) error
- func (c *Client) LoadMapsFromDB(ctx context.Context) error
- func (c *Client) SetHTTPDoer(d HTTPDoer)
- func (c *Client) StartUpdater(ctx context.Context)
- type ClubLogXML
- type CtyXML
- type DxccEntity
- type DxccException
- type DxccInfo
- type DxccPrefix
- type Entities
- type Entity
- type Exception
- type Exceptions
- type HTTPDoer
- type Prefix
- type Prefixes
Constants ยถ
const (
DBFileName = "dxcc.db" // Made public for use in main and tests
)
Variables ยถ
var FlagEmojis = map[string]string{
"1": "๐จ๐ฆ",
"291": "๐บ๐ธ",
"50": "๐ฒ๐ฝ",
"70": "๐จ๐บ",
"105": "๐บ๐ธ",
"100": "๐ฆ๐ท",
"108": "๐ง๐ท",
"144": "๐บ๐พ",
"112": "๐จ๐ฑ",
"116": "๐จ๐ด",
"136": "๐ต๐ช",
"140": "๐ป๐ช",
"120": "๐ช๐จ",
"124": "๐ฌ๐พ",
"132": "๐ต๐พ",
"129": "๐ฌ๐ซ",
"10": "๐ณ๐ฑ",
"14": "๐ฆ๐น",
"15": "๐ง๐ช",
"503": "๐จ๐ฟ",
"160": "๐ฉ๐ฐ",
"224": "๐ซ๐ฎ",
"227": "๐ซ๐ท",
"230": "๐ฉ๐ช",
"236": "๐ฌ๐ท",
"239": "๐ญ๐บ",
"251": "๐ฎ๐ธ",
"245": "๐ฎ๐ช",
"248": "๐ฎ๐น",
"260": "๐ฒ๐จ",
"266": "๐ณ๐ด",
"269": "๐ต๐ฑ",
"272": "๐ต๐น",
"54": "๐ท๐บ",
"281": "๐ช๐ธ",
"284": "๐ธ๐ช",
"287": "๐จ๐ญ",
"288": "๐บ๐ฆ",
"223": "๐ฌ๐ง",
"212": "๐ง๐ฌ",
"275": "๐ท๐ด",
"339": "๐ฏ๐ต",
"318": "๐จ๐ณ",
"137": "๐ฐ๐ท",
"324": "๐ฎ๐ณ",
"387": "๐น๐ญ",
"293": "๐ป๐ณ",
"327": "๐ฎ๐ฉ",
"375": "๐ต๐ญ",
"381": "๐ธ๐ฌ",
"333": "๐ฒ๐พ",
"390": "๐น๐ผ",
"321": "๐ญ๐ฐ",
"150": "๐ฆ๐บ",
"170": "๐ณ๐ฟ",
"176": "๐ซ๐ฏ",
"163": "๐ต๐ฌ",
"158": "๐ป๐บ",
"162": "๐ณ๐จ",
"175": "๐ต๐ซ",
"462": "๐ฟ๐ฆ",
"478": "๐ช๐ฌ",
"430": "๐ฐ๐ช",
"450": "๐ณ๐ฌ",
"446": "๐ฒ๐ฆ",
"474": "๐น๐ณ",
"438": "๐ฒ๐ฌ",
"453": "๐ท๐ช",
"165": "๐ฒ๐บ",
"13": "๐ฆ๐ถ",
"460": "",
"901": "",
}
FlagEmojis is a comprehensive mapping of DXCC ID (as string) to emoji flag. This covers the most common amateur radio countries and entities.
Functions ยถ
Types ยถ
type Client ยถ
type Client struct {
// Expose for testing
PrefixesMap map[string]DxccPrefix
ExceptionsMap map[string]DxccException
EntitiesMap map[int]DxccEntity
// Testing hook to override http client behavior
HTTPClient HTTPDoer
// TestFallback when true enables a small, test-only fallback mapping for missing entities.
TestFallback bool
// contains filtered or unexported fields
}
Client manages DXCC data.
func (*Client) FetchAndStore ยถ
FetchAndStore exposes the internal fetchAndStoreData for tests.
func (*Client) FetchAndStoreData ยถ
func (*Client) GetDxccInfo ยถ
func (c *Client) GetDxccInfo(ctx context.Context, callsign string, lookupDate *time.Time) (*DxccInfo, error)
GetDxccInfo performs a DXCC lookup for a given callsign. It also takes an optional 'lookupDate' for historical lookups, though current implementation mainly relies on current loaded data.
func (*Client) GetEntities ยถ
func (c *Client) GetEntities() map[int]DxccEntity
GetEntities exposes the internal entities map for tests.
func (*Client) GetException ยถ
GetException checks if a callsign has a hardcoded exception entry. Returns (entity, found).
func (*Client) GetExceptions ยถ
func (c *Client) GetExceptions() map[string]DxccException
GetExceptions exposes the internal exceptions map for tests.
func (*Client) GetHTTPClient ยถ
GetHTTPClient exposes the internal http client for tests.
func (*Client) GetLastDownloadTime ยถ
GetLastDownloadTime retrieves when DXCC data was last downloaded.
func (*Client) GetPrefix ยถ
GetPrefix looks up a prefix in the DXCC prefix map. Returns (entity, found).
func (*Client) GetPrefixes ยถ
func (c *Client) GetPrefixes() map[string]DxccPrefix
GetPrefixes exposes the internal prefixes map for tests.
func (*Client) LoadMapsFromDB ยถ
Compatibility aliases for tests: previous tests expect these names.
func (*Client) SetHTTPDoer ยถ
SetHTTPDoer allows tests to inject a custom HTTP client that satisfies HTTPDoer.
func (*Client) StartUpdater ยถ
StartUpdater starts the periodic update job for DXCC data. Note: Does NOT perform an initial check - main.go handles that synchronously before calling this.
type ClubLogXML ยถ
type ClubLogXML struct {
XMLName xml.Name `xml:"clublog"`
Date string `xml:"date,attr"`
Prefixes Prefixes `xml:"prefixes"`
Exceptions Exceptions `xml:"exceptions"`
Entities Entities `xml:"entities"`
}
ClubLogXML represents the root of the new Club Log XML format.
type CtyXML ยถ
type CtyXML struct {
XMLName xml.Name `xml:"cty"`
Prefixes Prefixes `xml:"prefixes"`
Exceptions Exceptions `xml:"exceptions"`
Entities Entities `xml:"entities"`
}
CtyXML represents the root of the legacy cty.xml file.
type DxccEntity ยถ
type DxccEntity struct {
ADIF int `json:"adif"`
Name string `json:"name"`
Prefix string `json:"prefix"`
ITUZ int `json:"ituz"`
CQZ int `json:"cqz"`
Cont string `json:"cont"`
Long float64 `json:"long"`
Lat float64 `json:"lat"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
}
DxccEntity represents a row in the dxcc_entities table.
type DxccException ยถ
type DxccException DxccPrefix // Same structure as DxccPrefix for simplicity
DxccException represents a row in the dxcc_exceptions table.
type DxccInfo ยถ
type DxccInfo struct {
Cont string `json:"cont"`
Entity string `json:"entity"`
Flag string `json:"flag"` // Emoji flag
DXCCID int `json:"dxcc_id"`
CQZ int `json:"cqz"`
ITUZ int `json:"ituz"`
Latitude float64 `json:"lat"`
Longitude float64 `json:"lng"`
}
DxccInfo holds comprehensive DXCC information for a callsign. This is the output format from the lookup.
type DxccPrefix ยถ
type DxccPrefix struct {
Call string `json:"call"`
Entity string `json:"entity"`
ADIF int `json:"adif"`
CQZ int `json:"cqz"`
Cont string `json:"cont"`
Long float64 `json:"long"`
Lat float64 `json:"lat"`
Start time.Time `json:"start"` // Stored as TEXT (ISO 8601) in DB
End time.Time `json:"end"` // Stored as TEXT (ISO 8601) in DB
}
DxccPrefix represents a row in the dxcc_prefixes table.
type Entity ยถ
type Entity struct {
XMLName xml.Name `xml:"entity"`
ADIF int `xml:"adif,attr"`
Name string `xml:"name"` // Often the same as 'entity' in prefix, but can differ.
Prefix string `xml:"prefix"` // Primary prefix for the entity
ITUZ int `xml:"ituz"` // ITU Zone is here
CQZ int `xml:"cqz"`
Cont string `xml:"cont"`
Long float64 `xml:"long"`
Lat float64 `xml:"lat"`
Start string `xml:"start"`
End string `xml:"end"`
}
Entity represents a single DXCC entity entry (for global entity data like ITU zone).
type Exception ยถ
type Exception struct {
XMLName xml.Name `xml:"exception"`
RecordID int `xml:"record,attr"`
Call string `xml:"call"`
Entity string `xml:"entity"`
ADIF int `xml:"adif"`
CQZ int `xml:"cqz"`
Cont string `xml:"cont"`
Long float64 `xml:"long"`
Lat float64 `xml:"lat"`
Start string `xml:"start"`
End string `xml:"end"`
}
Exception represents a single DXCC exception entry.
type Exceptions ยถ
type Exceptions struct {
XMLName xml.Name `xml:"exceptions"`
Exception []Exception `xml:"exception"`
}
Exceptions holds a list of Exception records.
type Prefix ยถ
type Prefix struct {
XMLName xml.Name `xml:"prefix"`
RecordID int `xml:"record,attr"` // 'record' attribute
Call string `xml:"call"`
Entity string `xml:"entity"`
ADIF int `xml:"adif"`
CQZ int `xml:"cqz"`
Cont string `xml:"cont"`
Long float64 `xml:"long"`
Lat float64 `xml:"lat"`
Start string `xml:"start"` // Will parse to time.Time
End string `xml:"end"` // Will parse to time.Time
}
Prefix represents a single DXCC prefix entry.