-
Notifications
You must be signed in to change notification settings - Fork 16
/
main.go
57 lines (50 loc) · 1.08 KB
/
main.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
48
49
50
51
52
53
54
55
56
57
package main
import (
"fmt"
"github.com/Boostport/address"
)
func main() {
addr, _ := address.NewValid(
address.WithCountry("AU"),
address.WithName("John Citizen"),
address.WithOrganization("Some Company Pty Ltd"),
address.WithStreetAddress([]string{
"525 Collins Street",
}),
address.WithLocality("Melbourne"),
address.WithAdministrativeArea("VIC"),
address.WithPostCode("3000"),
)
freeShippingToQLDAndNSW := address.Zone{
{
Country: "AU",
AdministrativeArea: "NSW",
},
{
Country: "AU",
AdministrativeArea: "QLD",
},
}
fmt.Println(freeShippingToQLDAndNSW.Contains(addr)) // false
victorianPostCodesExceptCarltonGetDiscount := address.Zone{
{
Country: "AU",
IncludedPostCodes: address.ExactMatcher{
Ranges: []address.PostCodeRange{
{
Start: 3000,
End: 3996,
},
{
Start: 8000,
End: 8873,
},
},
},
ExcludedPostCodes: address.ExactMatcher{
Matches: []string{"3053"},
},
},
}
fmt.Println(victorianPostCodesExceptCarltonGetDiscount.Contains(addr)) // true
}