Skip to content

Commit 652ee9d

Browse files
committed
Fix minor documentation errors and typos
1 parent db7502b commit 652ee9d

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

example_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ func ExampleReader_Networks() {
6666

6767
for result := range db.Networks() {
6868
record := struct {
69-
Domain string `maxminddb:"connection_type"`
69+
ConnectionType string `maxminddb:"connection_type"`
7070
}{}
7171

7272
err := result.Decode(&record)
7373
if err != nil {
7474
log.Panic(err)
7575
}
76-
fmt.Printf("%s: %s\n", result.Prefix(), record.Domain)
76+
fmt.Printf("%s: %s\n", result.Prefix(), record.ConnectionType)
7777
}
7878
// Output:
7979
// 1.0.0.0/24: Cable/DSL
@@ -151,13 +151,13 @@ func ExampleReader_NetworksWithin() {
151151

152152
for result := range db.NetworksWithin(prefix) {
153153
record := struct {
154-
Domain string `maxminddb:"connection_type"`
154+
ConnectionType string `maxminddb:"connection_type"`
155155
}{}
156156
err := result.Decode(&record)
157157
if err != nil {
158158
log.Panic(err)
159159
}
160-
fmt.Printf("%s: %s\n", result.Prefix(), record.Domain)
160+
fmt.Printf("%s: %s\n", result.Prefix(), record.ConnectionType)
161161
}
162162

163163
// Output:

reader.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,8 @@ func FromBytes(buffer []byte, options ...ReaderOption) (*Reader, error) {
342342
return reader, err
343343
}
344344

345-
// Lookup retrieves the database record for ip and returns Result, which can
346-
// be used to decode the data..
345+
// Lookup retrieves the database record for ip and returns a Result, which can
346+
// be used to decode the data.
347347
func (r *Reader) Lookup(ip netip.Addr) Result {
348348
if r.buffer == nil {
349349
return Result{err: errors.New("cannot call Lookup on a closed database")}
@@ -377,7 +377,7 @@ func (r *Reader) Lookup(ip netip.Addr) Result {
377377
// netip.Prefix returned by Networks will be invalid when using LookupOffset.
378378
func (r *Reader) LookupOffset(offset uintptr) Result {
379379
if r.buffer == nil {
380-
return Result{err: errors.New("cannot call Decode on a closed database")}
380+
return Result{err: errors.New("cannot call LookupOffset on a closed database")}
381381
}
382382

383383
return Result{decoder: r.decoder, offset: uint(offset)}

reader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ func TestUsingClosedDatabase(t *testing.T) {
712712
assert.Equal(t, "cannot call Lookup on a closed database", err.Error())
713713

714714
err = reader.LookupOffset(0).Decode(recordInterface)
715-
assert.Equal(t, "cannot call Decode on a closed database", err.Error())
715+
assert.Equal(t, "cannot call LookupOffset on a closed database", err.Error())
716716
}
717717

718718
func checkMetadata(t *testing.T, reader *Reader, ipVersion, recordSize uint) {

result.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (r Result) Found() bool {
100100
// passed to (*Reader).LookupOffset. It can also be used as a unique
101101
// identifier for the data record in the particular database to cache the data
102102
// record across lookups. Note that while the offset uniquely identifies the
103-
// data record, other data in Result may differ between lookups. The offset
103+
// data record, other data in Result may differ between lookups. The offset
104104
// is only valid for the current database version. If you update the database
105105
// file, you must invalidate any cache associated with the previous version.
106106
func (r Result) Offset() uintptr {

0 commit comments

Comments
 (0)