Skip to content

Commit 42e7f85

Browse files
committed
Do not reuse record between iterations in example
Although this is fine for the single value case, it can lead to misuse in more complicated cases.
1 parent 616cde2 commit 42e7f85

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

example_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ func ExampleReader_Networks() {
6363
}
6464
defer db.Close()
6565

66-
record := struct {
67-
Domain string `maxminddb:"connection_type"`
68-
}{}
69-
7066
networks := db.Networks(maxminddb.SkipAliasedNetworks)
7167
for networks.Next() {
68+
record := struct {
69+
Domain string `maxminddb:"connection_type"`
70+
}{}
71+
7272
subnet, err := networks.Network(&record)
7373
if err != nil {
7474
log.Panic(err)
@@ -114,17 +114,17 @@ func ExampleReader_NetworksWithin() {
114114
}
115115
defer db.Close()
116116

117-
record := struct {
118-
Domain string `maxminddb:"connection_type"`
119-
}{}
120-
121117
_, network, err := net.ParseCIDR("1.0.0.0/8")
122118
if err != nil {
123119
log.Panic(err)
124120
}
125121

126122
networks := db.NetworksWithin(network, maxminddb.SkipAliasedNetworks)
127123
for networks.Next() {
124+
record := struct {
125+
Domain string `maxminddb:"connection_type"`
126+
}{}
127+
128128
subnet, err := networks.Network(&record)
129129
if err != nil {
130130
log.Panic(err)

0 commit comments

Comments
 (0)