-
Notifications
You must be signed in to change notification settings - Fork 6
/
models.go
47 lines (39 loc) · 1.08 KB
/
models.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package caddy_geoip
import "strings"
type Names struct {
De string `maxminddb:"de"`
En string `maxminddb:"en"`
Es string `maxminddb:"es"`
Fr string `maxminddb:"fr"`
PtBr string `maxminddb:"pt-BR"`
Ru string `maxminddb:"ru"`
ZhCn string `maxminddb:"zh-CN"`
}
type Country struct {
GeonameId int `maxminddb:"geoname_id"`
IsInEuropeanUnion bool `maxminddb:"is_in_european_union"`
ISOCode string `maxminddb:"iso_code"`
Names Names `maxminddb:"names"`
}
type Subdivision struct {
ISOCode string `maxminddb:"iso_code"`
}
type Subdivisions []Subdivision
func (s Subdivisions) GetISOCodes() []string {
var result []string
for _, sub := range s {
result = append(result, sub.ISOCode)
}
return result
}
func (s Subdivisions) CommaSeparatedISOCodes() string {
return strings.Join(s.GetISOCodes(), ",")
}
type Location struct {
MetroCode int `maxminddb:"metro_code"`
}
type Record struct {
Country Country `maxminddb:"country"`
Location Location `maxminddb:"location"`
Subdivisions Subdivisions `maxminddb:"subdivisions"`
}