-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.go
33 lines (26 loc) · 1.04 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
package countries
import "errors"
// Language is a ISO 639-1 language code.
type Language string
const (
// DE is the german ISO 639-1 language code.
DE Language = "de"
// EN is for english ISO 639-1 language code.
EN Language = "en"
)
// Mapping holds a country code.
type Mapping struct {
Alpha2 string `json:"alpha2" example:"DE"`
Alpha3 string `json:"alpha3" example:"DEU"`
Translations map[Language]Translation `json:"translations"`
}
// Translation is a single translation for a country.
type Translation struct {
Common string `json:"common" example:"Germany"`
Official string `json:"official" example:"Germany"`
Nationality string `json:"nationality" example:"German"`
}
// ErrCountryNotFound indicates that the searched country was not found in our list.
var ErrCountryNotFound = errors.New("country not found")
// ErrTranslationNotFound indicates that the translation for the given language was not found in our list.
var ErrTranslationNotFound = errors.New("translation not found")