Skip to content

Commit f4aa557

Browse files
committed
Put example struct in example. Closes #31.
1 parent eccd8d6 commit f4aa557

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

example_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ import (
88
"github.com/oschwald/maxminddb-golang"
99
)
1010

11-
type onlyCountry struct {
12-
Country struct {
13-
ISOCode string `maxminddb:"iso_code"`
14-
} `maxminddb:"country"`
15-
}
16-
1711
// This example shows how to decode to a struct
1812
func ExampleReader_Lookup_struct() {
1913
db, err := maxminddb.Open("test-data/test-data/GeoIP2-City-Test.mmdb")
@@ -24,7 +18,12 @@ func ExampleReader_Lookup_struct() {
2418

2519
ip := net.ParseIP("81.2.69.142")
2620

27-
var record onlyCountry // Or any appropriate struct
21+
var record struct {
22+
Country struct {
23+
ISOCode string `maxminddb:"iso_code"`
24+
} `maxminddb:"country"`
25+
} // Or any appropriate struct
26+
2827
err = db.Lookup(ip, &record)
2928
if err != nil {
3029
log.Fatal(err)

0 commit comments

Comments
 (0)