Skip to content

Commit

Permalink
Merge pull request #80 from maxmind/greg/update-golangci-lint-conf
Browse files Browse the repository at this point in the history
Update golangci-lint config
  • Loading branch information
faktas2 committed Apr 8, 2024
2 parents 6daa3ad + 9526ab7 commit 8215424
Show file tree
Hide file tree
Showing 9 changed files with 274 additions and 397 deletions.
636 changes: 253 additions & 383 deletions .golangci.toml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion data_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package mmdbwriter
import (
"bytes"
"crypto/sha256"
"fmt"
"hash"

"github.com/maxmind/mmdbwriter/mmdbtype"
Expand Down Expand Up @@ -48,7 +49,7 @@ func (kw *keyWriter) Key(v mmdbtype.DataType) ([]byte, error) {
return nil, err
}
if _, err := kw.WriteTo(kw.sha256); err != nil {
return nil, err
return nil, fmt.Errorf("writing key to writer: %w", err)
}
return kw.sha256.Sum(kw.key[:0]), nil
}
Expand Down
3 changes: 2 additions & 1 deletion data_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package mmdbwriter
import (
"testing"

"github.com/maxmind/mmdbwriter/mmdbtype"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/maxmind/mmdbwriter/mmdbtype"
)

func TestDataMap(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion data_section_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package mmdbwriter
import (
"testing"

"github.com/maxmind/mmdbwriter/mmdbtype"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/maxmind/mmdbwriter/mmdbtype"
)

func TestDisablingPointers(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion inserter/inserter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package inserter
import (
"testing"

"github.com/maxmind/mmdbwriter/mmdbtype"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/maxmind/mmdbwriter/mmdbtype"
)

func TestRemove(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion mmdbtype/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func TestString(t *testing.T) {
}

func TestByte(t *testing.T) {
b := make(map[string]DataType)
b := map[string]DataType{}
for key, val := range testStrings {
oldCtrl, err := hex.DecodeString(key[0:2])
require.NoError(t, err)
Expand Down
1 change: 1 addition & 0 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func (r *record) insert(
} else if oldData == nil || !oldData.Equal(newData) {
iRec.dataMap.remove(r.value)
value, err := iRec.dataMap.store(newData)
//nolint:revive //preexisting
if err != nil {
return err
}
Expand Down
15 changes: 8 additions & 7 deletions tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import (
"net"
"time"

"github.com/maxmind/mmdbwriter/inserter"
"github.com/maxmind/mmdbwriter/mmdbtype"
"github.com/oschwald/maxminddb-golang"
"go4.org/netipx"

"github.com/maxmind/mmdbwriter/inserter"
"github.com/maxmind/mmdbwriter/mmdbtype"
)

var (
Expand Down Expand Up @@ -180,7 +181,7 @@ func New(opts Options) (*Tree, error) {
func Load(path string, opts Options) (*Tree, error) {
db, err := maxminddb.Open(path)
if err != nil {
return nil, err
return nil, fmt.Errorf("opening %s: %w", path, err)
}
defer db.Close()

Expand Down Expand Up @@ -224,7 +225,7 @@ func Load(path string, opts Options) (*Tree, error) {
dser.clear()
network, err = networks.Network(dser)
if err != nil {
return nil, err
return nil, fmt.Errorf("unmarshaling record for network: %w", err)
}

err = tree.Insert(network, dser.rv)
Expand All @@ -233,7 +234,7 @@ func Load(path string, opts Options) (*Tree, error) {
}
}
if err := networks.Err(); err != nil {
return nil, err
return nil, fmt.Errorf("iterating over networks: %w", err)
}
return tree, nil
}
Expand Down Expand Up @@ -494,7 +495,7 @@ func (t *Tree) WriteTo(w io.Writer) (int64, error) {
nb64, err := dataWriter.WriteTo(buf)
numBytes += nb64
if err != nil {
return numBytes, err
return numBytes, fmt.Errorf("writing data to buffer: %w", err)
}

nb, err = buf.Write(metadataStartMarker)
Expand All @@ -520,7 +521,7 @@ func (t *Tree) WriteTo(w io.Writer) (int64, error) {
return numBytes, fmt.Errorf("flushing buffer to writer: %w", err)
}

return numBytes, err
return numBytes, nil
}

func (t *Tree) writeNode(
Expand Down
5 changes: 3 additions & 2 deletions tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import (
"testing"
"time"

"github.com/maxmind/mmdbwriter/inserter"
"github.com/maxmind/mmdbwriter/mmdbtype"
"github.com/oschwald/maxminddb-golang"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/maxmind/mmdbwriter/inserter"
"github.com/maxmind/mmdbwriter/mmdbtype"
)

type testInsert struct {
Expand Down

0 comments on commit 8215424

Please sign in to comment.