Skip to content

Commit

Permalink
add goimports to golangci-lint to sort imports (#63)
Browse files Browse the repository at this point in the history
* add goimports to golangci-lint to sort imports

---------

Co-authored-by: Naveen <[email protected]>
  • Loading branch information
silentcanon and naveen246 authored Jan 24, 2025
1 parent dc27d2f commit f333b92
Show file tree
Hide file tree
Showing 56 changed files with 216 additions and 116 deletions.
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
linters:
enable:
- goimports
linters-settings:
goimports:
local-prefixes: github.com/slatedb/slatedb-go
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ LINT = $(GOPATH)/bin/golangci-lint
LINT_VERSION = v1.61.0

$(LINT): ## Download Go linter
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin $(LINT_VERSION)
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin $(LINT_VERSION)

.PHONY: lint
lint: $(LINT) ## Run Go linter
$(LINT) run -v ./...

format_imports:
go install golang.org/x/tools/cmd/goimports@latest
goimports -l -w .

fmt:
go fmt ./...

Expand All @@ -20,7 +24,7 @@ flatbuf:
go fmt ./internal/flatbuf/*.go

.PHONY: build
build: flatbuf fmt vet
build: flatbuf fmt vet format_imports
go build -v -o bin/slatedb -race ./cmd

test_coverage:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ SlateDB is licensed under the Apache License, Version 2.0.

1. Why is there a Go port instead of using Go binding ?

We wanted developers using this library in Go to be able to easily understand and modify(if needed) the internals without having to learn a new language.
We wanted developers using this library in Go to be able to easily understand and modify(if needed) the internals without having to learn a new language.

Go developers will also have an option to use Go binding(when it is ready) if they can use cgo/ffi.
Go developers will also have an option to use Go binding(when it is ready) if they can use cgo/ffi.


2. Is there a risk of a drift between the inner workings of the Rust and Go implementation?

We will try to keep it close to the Rust implementation.
We will try to keep it close to the Rust implementation.
3 changes: 2 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
"log/slog"
"time"

"github.com/slatedb/slatedb-go/slatedb"
"github.com/thanos-io/objstore"

"github.com/slatedb/slatedb-go/slatedb"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/slatedb/slatedb-go

go 1.23.1
go 1.23

require (
github.com/gammazero/deque v0.2.1
Expand Down
6 changes: 4 additions & 2 deletions internal/assert/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package assert
import (
"context"
"fmt"
"github.com/slatedb/slatedb-go/internal/iter"
assert2 "github.com/stretchr/testify/assert"
"testing"

assert2 "github.com/stretchr/testify/assert"

"github.com/slatedb/slatedb-go/internal/iter"
)

func True(condition bool, errMsg string, arg ...any) {
Expand Down
4 changes: 3 additions & 1 deletion internal/compress/compression.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import (
"bytes"
"compress/zlib"
"errors"
"io"

"github.com/golang/snappy"
"github.com/klauspost/compress/zstd"
"github.com/pierrec/lz4/v4"

"github.com/slatedb/slatedb-go/internal/flatbuf"
"io"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion internal/flatbuf/manifest_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/iter/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package iter

import (
"context"

"github.com/slatedb/slatedb-go/internal/types"
)

Expand Down
6 changes: 4 additions & 2 deletions internal/iter/entry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package iter_test

import (
"context"
"github.com/slatedb/slatedb-go/internal/iter"
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"

"github.com/slatedb/slatedb-go/internal/iter"
)

func TestNewEntryIterator(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions internal/iter/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"cmp"
"container/heap"
"context"

"github.com/slatedb/slatedb-go/internal/types"
)

Expand Down
6 changes: 4 additions & 2 deletions internal/iter/merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package iter_test

import (
"context"
"testing"

"github.com/stretchr/testify/assert"

assert2 "github.com/slatedb/slatedb-go/internal/assert"
"github.com/slatedb/slatedb-go/internal/iter"
"github.com/stretchr/testify/assert"
"testing"
)

func TestMergeUniqueIteratorPrecedence(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions internal/sstable/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sstable

import (
"errors"

"github.com/slatedb/slatedb-go/slatedb/common"
)

Expand Down
3 changes: 2 additions & 1 deletion internal/sstable/block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"encoding/binary"
"errors"
"fmt"
"hash/crc32"

"github.com/slatedb/slatedb-go/internal/assert"
"github.com/slatedb/slatedb-go/internal/compress"
"github.com/slatedb/slatedb-go/internal/types"
"github.com/slatedb/slatedb-go/slatedb/common"
"hash/crc32"
)

var (
Expand Down
10 changes: 6 additions & 4 deletions internal/sstable/block/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ import (
"bytes"
"context"
"encoding/binary"
"hash/crc32"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

assert2 "github.com/slatedb/slatedb-go/internal/assert"
"github.com/slatedb/slatedb-go/internal/compress"
"github.com/slatedb/slatedb-go/internal/sstable/block"
"github.com/slatedb/slatedb-go/internal/types"
"github.com/slatedb/slatedb-go/slatedb/common"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"hash/crc32"
"testing"
)

func TestNewBuilder(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion internal/sstable/block/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"context"
"errors"
"fmt"
"github.com/slatedb/slatedb-go/internal/types"
"sort"

"github.com/slatedb/slatedb-go/internal/types"
)

// Iterator iterates through KeyValue pairs present in the Block.
Expand Down
5 changes: 3 additions & 2 deletions internal/sstable/block/row.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"bytes"
"encoding/binary"
"errors"
"math"
"time"

"github.com/slatedb/slatedb-go/internal/assert"
"github.com/slatedb/slatedb-go/internal/types"
"github.com/slatedb/slatedb-go/slatedb/common"
"math"
"time"
)

var v0RowCodec v0Codec
Expand Down
10 changes: 6 additions & 4 deletions internal/sstable/block/row_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package block

import (
"bytes"
"testing"
"time"

"github.com/kapetan-io/tackle/random"
"github.com/slatedb/slatedb-go/internal/compress"
"github.com/slatedb/slatedb-go/internal/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
"time"

"github.com/slatedb/slatedb-go/internal/compress"
"github.com/slatedb/slatedb-go/internal/types"
)

func TestRowFlags(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions internal/sstable/bloom/bloom.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package bloom
import (
"encoding/binary"
"errors"
"github.com/slatedb/slatedb-go/internal/compress"
"github.com/slatedb/slatedb-go/slatedb/common"
"hash/crc32"
"hash/fnv"

"github.com/slatedb/slatedb-go/internal/compress"
"github.com/slatedb/slatedb-go/slatedb/common"
)

type Filter struct {
Expand Down
8 changes: 5 additions & 3 deletions internal/sstable/bloom/bloom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package bloom
import (
"encoding/binary"
"fmt"
"github.com/slatedb/slatedb-go/internal/compress"
"github.com/slatedb/slatedb-go/slatedb/common"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"

"github.com/slatedb/slatedb-go/internal/compress"
"github.com/slatedb/slatedb-go/slatedb/common"
)

func TestFilterBuilder_Build(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions internal/sstable/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package sstable
import (
"bytes"
"encoding/binary"

"github.com/gammazero/deque"
"github.com/samber/mo"

"github.com/slatedb/slatedb-go/internal/assert"
"github.com/slatedb/slatedb-go/internal/compress"
"github.com/slatedb/slatedb-go/internal/flatbuf"
Expand Down
8 changes: 5 additions & 3 deletions internal/sstable/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ package sstable_test

import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

assert2 "github.com/slatedb/slatedb-go/internal/assert"
"github.com/slatedb/slatedb-go/internal/compress"
"github.com/slatedb/slatedb-go/internal/sstable"
"github.com/slatedb/slatedb-go/internal/sstable/block"
"github.com/slatedb/slatedb-go/internal/types"
"github.com/slatedb/slatedb-go/slatedb/common"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)

func TestBuilder(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions internal/sstable/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package sstable
import (
"encoding/binary"
"fmt"

"github.com/samber/mo"

"github.com/slatedb/slatedb-go/internal/compress"
"github.com/slatedb/slatedb-go/internal/sstable/block"
"github.com/slatedb/slatedb-go/internal/sstable/bloom"
Expand Down
6 changes: 4 additions & 2 deletions internal/sstable/flatbuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package sstable
import (
"bytes"
"encoding/binary"
"github.com/google/flatbuffers/go"
"hash/crc32"

flatbuffers "github.com/google/flatbuffers/go"

"github.com/slatedb/slatedb-go/internal/compress"
"github.com/slatedb/slatedb-go/internal/flatbuf"
"github.com/slatedb/slatedb-go/slatedb/common"
"hash/crc32"
)

type Index struct {
Expand Down
1 change: 1 addition & 0 deletions internal/sstable/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"

"github.com/slatedb/slatedb-go/internal/sstable/block"
"github.com/slatedb/slatedb-go/internal/types"
"github.com/slatedb/slatedb-go/slatedb/common"
Expand Down
3 changes: 2 additions & 1 deletion internal/sstable/pretty.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package sstable
import (
"bytes"
"fmt"
"github.com/slatedb/slatedb-go/internal/sstable/block"
"strings"

"github.com/slatedb/slatedb-go/internal/sstable/block"
)

// PrettyPrint returns a string representation of the SSTable in a human-readable format
Expand Down
6 changes: 4 additions & 2 deletions internal/sstable/pretty_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package sstable

import (
"github.com/slatedb/slatedb-go/internal/compress"
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"

"github.com/slatedb/slatedb-go/internal/compress"
)

func TestPrettyPrint(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions internal/sstable/sstable.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sstable

import (
"bytes"

"github.com/slatedb/slatedb-go/internal/compress"
)

Expand Down
8 changes: 5 additions & 3 deletions internal/sstable/sstable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package sstable_test

import (
"bytes"
"github.com/slatedb/slatedb-go/internal/compress"
"github.com/slatedb/slatedb-go/internal/sstable"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"

"github.com/slatedb/slatedb-go/internal/compress"
"github.com/slatedb/slatedb-go/internal/sstable"
)

func TestInfoClone(t *testing.T) {
Expand Down
Loading

0 comments on commit f333b92

Please sign in to comment.