Skip to content

Commit

Permalink
Do not reuse record between iterations in example
Browse files Browse the repository at this point in the history
Although this is fine for the single value case, it can lead to misuse
in more complicated cases.
  • Loading branch information
oschwald committed Aug 3, 2024
1 parent 616cde2 commit 42e7f85
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ func ExampleReader_Networks() {
}
defer db.Close()

record := struct {
Domain string `maxminddb:"connection_type"`
}{}

networks := db.Networks(maxminddb.SkipAliasedNetworks)
for networks.Next() {
record := struct {
Domain string `maxminddb:"connection_type"`
}{}

subnet, err := networks.Network(&record)
if err != nil {
log.Panic(err)
Expand Down Expand Up @@ -114,17 +114,17 @@ func ExampleReader_NetworksWithin() {
}
defer db.Close()

record := struct {
Domain string `maxminddb:"connection_type"`
}{}

_, network, err := net.ParseCIDR("1.0.0.0/8")
if err != nil {
log.Panic(err)
}

networks := db.NetworksWithin(network, maxminddb.SkipAliasedNetworks)
for networks.Next() {
record := struct {
Domain string `maxminddb:"connection_type"`
}{}

subnet, err := networks.Network(&record)
if err != nil {
log.Panic(err)
Expand Down

0 comments on commit 42e7f85

Please sign in to comment.