Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ jobs:
;;
esac
- name: golangci-lint
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
with:
version: v1.64.8
version: v2.4.0

test-windows:
strategy:
Expand Down Expand Up @@ -88,9 +88,9 @@ jobs:
esac
shell: bash
- name: golangci-lint
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
with:
version: v1.64.8
version: v2.4.0

coverage:
needs: ["test-linux", "test-windows"]
Expand Down
34 changes: 34 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
formatters:
enable:
- gofmt
- goimports
settings: # please keep this alphabetized
goimports:
local-prefixes:
- go.etcd.io # Put imports beginning with prefix after 3rd-party packages.
issues:
max-same-issues: 0
linters:
default: none
enable: # please keep this alphabetized
- errcheck
- govet
- ineffassign
- staticcheck
- unused
exclusions:
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
settings: # please keep this alphabetized
staticcheck:
checks:
- all
- -QF1003 # Convert if/else-if chain to tagged switch
- -QF1010 # Convert slice of bytes to string when printing it
- -ST1003 # Poorly chosen identifier
- -ST1005 # Incorrectly formatted error string
- -ST1012 # Poorly chosen name for error variable
version: "2"
8 changes: 4 additions & 4 deletions bucket.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package bbolt

Check failure on line 1 in bucket.go

View workflow job for this annotation

GitHub Actions / test-windows (windows-amd64-unit-test-4-cpu)

File is not properly formatted (gofmt)

import (
"bytes"
Expand Down Expand Up @@ -343,7 +343,7 @@
}

// Sequence returns the current integer for the bucket without incrementing it.
func (b *Bucket) Sequence() uint64 { return b.bucket.sequence }
func (b *Bucket) Sequence() uint64 { return b.sequence }

// SetSequence updates the sequence number for the bucket.
func (b *Bucket) SetSequence(v uint64) error {
Expand All @@ -360,7 +360,7 @@
}

// Set the sequence.
b.bucket.sequence = v
b.sequence = v
return nil
}

Expand All @@ -379,8 +379,8 @@
}

// Increment and return the sequence.
b.bucket.sequence++
return b.bucket.sequence, nil
b.sequence++
return b.sequence, nil
}

// ForEach executes a function for each key/value pair in a bucket.
Expand Down
11 changes: 5 additions & 6 deletions cmd/bbolt/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main

Check failure on line 1 in cmd/bbolt/main.go

View workflow job for this annotation

GitHub Actions / test-windows (windows-amd64-unit-test-4-cpu)

File is not properly formatted (gofmt)

import (
"bytes"
Expand All @@ -21,9 +21,8 @@
"unicode/utf8"
"unsafe"

"go.etcd.io/bbolt/internal/guts_cli"

bolt "go.etcd.io/bbolt"
"go.etcd.io/bbolt/internal/guts_cli"
)

var (
Expand Down Expand Up @@ -934,7 +933,7 @@
// Print keys.
return db.View(func(tx *bolt.Tx) error {
// Find bucket.
var lastbucket *bolt.Bucket = tx.Bucket([]byte(buckets[0]))
lastbucket := tx.Bucket([]byte(buckets[0]))
if lastbucket == nil {
return ErrBucketNotFound
}
Expand Down Expand Up @@ -1028,7 +1027,7 @@
// Print value.
return db.View(func(tx *bolt.Tx) error {
// Find bucket.
var lastbucket *bolt.Bucket = tx.Bucket([]byte(buckets[0]))
lastbucket := tx.Bucket([]byte(buckets[0]))
if lastbucket == nil {
return ErrBucketNotFound
}
Expand Down Expand Up @@ -1692,11 +1691,11 @@

type cmdKvStringer struct{}

func (_ cmdKvStringer) KeyToString(key []byte) string {
func (cmdKvStringer) KeyToString(key []byte) string {
return bytesToAsciiOrHex(key)
}

func (_ cmdKvStringer) ValueToString(value []byte) string {
func (cmdKvStringer) ValueToString(value []byte) string {
return bytesToAsciiOrHex(value)
}

Expand Down
3 changes: 1 addition & 2 deletions cmd/bbolt/main_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main_test

Check failure on line 1 in cmd/bbolt/main_test.go

View workflow job for this annotation

GitHub Actions / test-windows (windows-amd64-unit-test-4-cpu)

File is not properly formatted (gofmt)

import (
"bytes"
Expand All @@ -10,12 +10,11 @@
"strconv"
"testing"

"go.etcd.io/bbolt/internal/btesting"

"github.com/stretchr/testify/require"

bolt "go.etcd.io/bbolt"
main "go.etcd.io/bbolt/cmd/bbolt"
"go.etcd.io/bbolt/internal/btesting"
)

// Ensure the "info" command can print information about a database.
Expand Down
1 change: 1 addition & 0 deletions internal/surgeon/surgeon.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package surgeon

import (
"fmt"

"go.etcd.io/bbolt/internal/guts_cli"
)

Expand Down
10 changes: 5 additions & 5 deletions page.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,16 @@ func (s pgids) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s pgids) Less(i, j int) bool { return s[i] < s[j] }

// merge returns the sorted union of a and b.
func (a pgids) merge(b pgids) pgids {
func (s pgids) merge(b pgids) pgids {
// Return the opposite slice if one is nil.
if len(a) == 0 {
if len(s) == 0 {
return b
}
if len(b) == 0 {
return a
return s
}
merged := make(pgids, len(a)+len(b))
mergepgids(merged, a, b)
merged := make(pgids, len(s)+len(b))
mergepgids(merged, s, b)
return merged
}

Expand Down
4 changes: 2 additions & 2 deletions tests/dmflakey/dmflakey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
"testing"
"time"

testutils "go.etcd.io/bbolt/tests/utils"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/sys/unix"

testutils "go.etcd.io/bbolt/tests/utils"
)

func TestMain(m *testing.M) {
Expand Down
6 changes: 3 additions & 3 deletions tests/robustness/powerfailure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import (
"testing"
"time"

"go.etcd.io/bbolt/tests/dmflakey"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/sys/unix"

"go.etcd.io/bbolt/tests/dmflakey"
)

var panicFailpoints = []string{
Expand Down Expand Up @@ -140,7 +140,7 @@ func TestRestartFromPowerFailureXFS(t *testing.T) {
}

func doPowerFailure(t *testing.T, du time.Duration, fsType dmflakey.FSType, mkfsOpt string, fsMountOpt string, useFailpoint bool) {
flakey := initFlakeyDevice(t, strings.Replace(t.Name(), "/", "_", -1), fsType, mkfsOpt, fsMountOpt)
flakey := initFlakeyDevice(t, strings.ReplaceAll(t.Name(), "/", "_"), fsType, mkfsOpt, fsMountOpt)
root := flakey.RootFS()

dbPath := filepath.Join(root, "boltdb")
Expand Down
4 changes: 2 additions & 2 deletions tx_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ func HexKVStringer() KVStringer {

type hexKvStringer struct{}

func (_ hexKvStringer) KeyToString(key []byte) string {
func (hexKvStringer) KeyToString(key []byte) string {
return hex.EncodeToString(key)
}

func (_ hexKvStringer) ValueToString(value []byte) string {
func (hexKvStringer) ValueToString(value []byte) string {
return hex.EncodeToString(value)
}
Loading