1package mapping
2
3import (
4 "github.com/biter777/countries"
5 "github.com/jphastings/dotpostcard/types"
6)
7
8type Countries map[string]struct{}
9
10func (list Countries) Codes() []string {
11 var codes []string
12 for code := range list {
13 codes = append(codes, code)
14 }
15 return codes
16}
17
18func (list Countries) Add(l types.Location) error {
19 c := countries.ByName(l.CountryCode)
20 list[c.Alpha2()] = struct{}{}
21 return nil
22}