Fix goimports and scripts.

Signed-off-by: Piotr Tabor <ptab@google.com>
pull/361/head
Piotr Tabor 2023-01-03 17:56:57 +01:00
parent 8961219de8
commit 9f841cc213
6 changed files with 23 additions and 8 deletions

View File

@ -5,14 +5,16 @@ import (
crypto "crypto/rand"
"encoding/binary"
"fmt"
"go.etcd.io/bbolt/internal/btesting"
"io"
"math/rand"
"os"
"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"
)

View File

@ -136,6 +136,8 @@ func (p *Page) Overflow() uint32 {
}
// DO NOT EDIT. Copied from the "bolt" package.
// TODO(ptabor): Make the page-types an enum.
func (p *Page) Type() string {
if (p.flags & branchPageFlag) != 0 {
return "branch"

View File

@ -2,11 +2,13 @@ package surgeon_test
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
bolt "go.etcd.io/bbolt"
"go.etcd.io/bbolt/internal/btesting"
"go.etcd.io/bbolt/internal/surgeon"
"testing"
)
func TestRevertMetaPage(t *testing.T) {

View File

@ -69,9 +69,9 @@ func (n XRay) traverseInternal(stack []guts_cli.Pgid, callback func(page *guts_c
return nil
}
// FindPathToPagesWithKey finds a path (from root to the page that contains the given key.
// As it traverses multiple buckets, in theory there might be multiple keys with given name.
// Note: For simplicity it's currently implemented as traversing whole reachable tree.
// FindPathToPagesWithKey finds all paths from root to the page that contains the given key.
// As it traverses multiple buckets, so in theory there might be multiple keys with the given name.
// Note: For simplicity it's currently implemented as traversing of the whole reachable tree.
func (n XRay) FindPathToPagesWithKey(key []byte) ([][]guts_cli.Pgid, error) {
var found [][]guts_cli.Pgid

View File

@ -2,11 +2,13 @@ package surgeon_test
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"go.etcd.io/bbolt/internal/btesting"
"go.etcd.io/bbolt/internal/guts_cli"
"go.etcd.io/bbolt/internal/surgeon"
"testing"
)
func TestNavigator_FindPathToPagesWithKey(t *testing.T) {

View File

@ -1,3 +1,10 @@
#!/bin/bash
GO_CMD="go"
go list --f '{{with $d:=.}}{{range .GoFiles}}{{$d.Dir}}/{{.}}{{"\n"}}{{end}}{{end}}' ./... | xargs go run golang.org/x/tools/cmd/goimports@latest -w -local go.etcd.io
GOFILES=$(${GO_CMD} list --f "{{with \$d:=.}}{{range .GoFiles}}{{\$d.Dir}}/{{.}}{{\"\n\"}}{{end}}{{end}}" ./...)
TESTGOFILES=$(${GO_CMD} list --f "{{with \$d:=.}}{{range .TestGoFiles}}{{\$d.Dir}}/{{.}}{{\"\n\"}}{{end}}{{end}}" ./...)
XTESTGOFILES=$(${GO_CMD} list --f "{{with \$d:=.}}{{range .XTestGoFiles}}{{\$d.Dir}}/{{.}}{{\"\n\"}}{{end}}{{end}}" ./...)
echo "${GOFILES}" "${TESTGOFILES}" "${XTESTGOFILES}"| xargs -n 100 go run golang.org/x/tools/cmd/goimports@latest -w -local go.etcd.io
go fmt ./...