Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: enable gci #8925

Merged
merged 2 commits into from
Dec 17, 2024
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 8 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ linters:
- protogetter
- reassign
- intrange
- gci
linters-settings:
gocritic:
# Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty
Expand Down Expand Up @@ -233,6 +234,13 @@ linters-settings:
desc: "Use 'sync/atomic' instead of 'go.uber.org/atomic'"
- pkg: github.com/pkg/errors
desc: "Use 'github.com/pingcap/errors' instead of 'github.com/pkg/errors'"
gci:
sections:
- standard
- default
- prefix(github.com/pingcap)
- prefix(github.com/tikv/pd)
- blank
issues:
exclude-rules:
- path: (_test\.go|pkg/mock/.*\.go|tests/.*\.go)
Expand Down
6 changes: 3 additions & 3 deletions client/circuitbreaker/circuit_breaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import (
"sync"
"time"

"github.com/tikv/pd/client/errs"

"github.com/prometheus/client_golang/prometheus"
m "github.com/tikv/pd/client/metrics"
"go.uber.org/zap"

"github.com/pingcap/log"

"github.com/tikv/pd/client/errs"
m "github.com/tikv/pd/client/metrics"
)

// Overloading is a type describing service return value
Expand Down
4 changes: 2 additions & 2 deletions client/circuitbreaker/circuit_breaker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
"testing"
"time"

"github.com/tikv/pd/client/errs"

"github.com/stretchr/testify/require"

"github.com/tikv/pd/client/errs"
)

// advance emulate the state machine clock moves forward by the given duration
Expand Down
9 changes: 5 additions & 4 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ import (
"sync"
"time"

cb "github.com/tikv/pd/client/circuitbreaker"

"github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus"
"go.uber.org/zap"

"github.com/pingcap/errors"
"github.com/pingcap/failpoint"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/pingcap/log"
"github.com/prometheus/client_golang/prometheus"

cb "github.com/tikv/pd/client/circuitbreaker"
"github.com/tikv/pd/client/clients/metastorage"
"github.com/tikv/pd/client/clients/router"
"github.com/tikv/pd/client/clients/tso"
Expand All @@ -41,7 +43,6 @@ import (
"github.com/tikv/pd/client/pkg/caller"
"github.com/tikv/pd/client/pkg/utils/tlsutil"
sd "github.com/tikv/pd/client/servicediscovery"
"go.uber.org/zap"
)

// GlobalConfigItem standard format of KV pair in GlobalConfig client
Expand Down
3 changes: 2 additions & 1 deletion client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import (
"time"

"github.com/stretchr/testify/require"
"go.uber.org/goleak"

"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/pkg/caller"
"github.com/tikv/pd/client/pkg/utils/testutil"
"github.com/tikv/pd/client/pkg/utils/tsoutil"
"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
Expand Down
1 change: 1 addition & 0 deletions client/clients/metastorage/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"

"github.com/pingcap/kvproto/pkg/meta_storagepb"

"github.com/tikv/pd/client/opt"
)

Expand Down
1 change: 1 addition & 0 deletions client/clients/router/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"net/url"

"github.com/pingcap/kvproto/pkg/metapb"

"github.com/tikv/pd/client/opt"
)

Expand Down
12 changes: 7 additions & 5 deletions client/clients/tso/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,23 @@ import (
"sync/atomic"
"time"

"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
healthpb "google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/status"

"github.com/pingcap/errors"
"github.com/pingcap/failpoint"
"github.com/pingcap/log"

"github.com/tikv/pd/client/constants"
"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/metrics"
"github.com/tikv/pd/client/opt"
"github.com/tikv/pd/client/pkg/utils/grpcutil"
"github.com/tikv/pd/client/pkg/utils/tlsutil"
sd "github.com/tikv/pd/client/servicediscovery"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
healthpb "google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/status"
)

const (
Expand Down
4 changes: 3 additions & 1 deletion client/clients/tso/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ import (
"time"

"github.com/opentracing/opentracing-go"
"go.uber.org/zap"

"github.com/pingcap/errors"
"github.com/pingcap/failpoint"
"github.com/pingcap/log"

"github.com/tikv/pd/client/constants"
"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/metrics"
Expand All @@ -37,7 +40,6 @@ import (
"github.com/tikv/pd/client/pkg/utils/timerutil"
"github.com/tikv/pd/client/pkg/utils/tsoutil"
sd "github.com/tikv/pd/client/servicediscovery"
"go.uber.org/zap"
)

// deadline is used to control the TS request timeout manually,
Expand Down
8 changes: 5 additions & 3 deletions client/clients/tso/dispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ import (
"testing"
"time"

"github.com/pingcap/failpoint"
"github.com/pingcap/log"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"go.uber.org/zap/zapcore"

"github.com/pingcap/failpoint"
"github.com/pingcap/log"

"github.com/tikv/pd/client/opt"
sd "github.com/tikv/pd/client/servicediscovery"
"go.uber.org/zap/zapcore"
)

type mockTSOServiceProvider struct {
Expand Down
1 change: 1 addition & 0 deletions client/clients/tso/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"time"

"github.com/pingcap/errors"

"github.com/tikv/pd/client/metrics"
)

Expand Down
3 changes: 2 additions & 1 deletion client/clients/tso/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ import (
"context"
"testing"

"github.com/pingcap/errors"
"github.com/stretchr/testify/require"

"github.com/pingcap/errors"
)

func TestTsoRequestWait(t *testing.T) {
Expand Down
8 changes: 5 additions & 3 deletions client/clients/tso/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@ import (
"sync/atomic"
"time"

"github.com/prometheus/client_golang/prometheus"
"go.uber.org/zap"
"google.golang.org/grpc"

"github.com/pingcap/errors"
"github.com/pingcap/failpoint"
"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/pingcap/kvproto/pkg/tsopb"
"github.com/pingcap/log"
"github.com/prometheus/client_golang/prometheus"

"github.com/tikv/pd/client/constants"
"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/metrics"
"go.uber.org/zap"
"google.golang.org/grpc"
)

// TSO Stream Builder Factory
Expand Down
8 changes: 5 additions & 3 deletions client/clients/tso/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ import (
"testing"
"time"

"github.com/pingcap/errors"
"github.com/pingcap/log"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/tikv/pd/client/errs"
"go.uber.org/zap/zapcore"

"github.com/pingcap/errors"
"github.com/pingcap/log"

"github.com/tikv/pd/client/errs"
)

const mockStreamURL = "mock:///"
Expand Down
3 changes: 2 additions & 1 deletion client/errs/errs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ package errs
import (
"strings"

"github.com/pingcap/errors"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"google.golang.org/grpc/codes"

"github.com/pingcap/errors"
)

// IsLeaderChange will determine whether there is a leader/primary change.
Expand Down
4 changes: 3 additions & 1 deletion client/gc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ import (
"time"

"github.com/opentracing/opentracing-go"
"go.uber.org/zap"

"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/pingcap/log"

"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/metrics"
"go.uber.org/zap"
)

// GCClient is a client for doing GC
Expand Down
6 changes: 4 additions & 2 deletions client/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ import (
"net/http"
"time"

"github.com/prometheus/client_golang/prometheus"
"go.uber.org/zap"

"github.com/pingcap/errors"
"github.com/pingcap/log"
"github.com/prometheus/client_golang/prometheus"

"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/pkg/retry"
sd "github.com/tikv/pd/client/servicediscovery"
"go.uber.org/zap"
)

const (
Expand Down
1 change: 1 addition & 0 deletions client/http/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"time"

"github.com/stretchr/testify/require"

"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/pkg/retry"
)
Expand Down
1 change: 1 addition & 0 deletions client/http/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/pingcap/kvproto/pkg/keyspacepb"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/kvproto/pkg/pdpb"

"github.com/tikv/pd/client/pkg/retry"
)

Expand Down
3 changes: 2 additions & 1 deletion client/http/request_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ package http
import (
"fmt"

"github.com/tikv/pd/client/pkg/retry"
"go.uber.org/zap"

"github.com/tikv/pd/client/pkg/retry"
)

// The following constants are the names of the requests.
Expand Down
1 change: 1 addition & 0 deletions client/http/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/pingcap/kvproto/pkg/encryptionpb"
"github.com/pingcap/kvproto/pkg/keyspacepb"
"github.com/pingcap/kvproto/pkg/pdpb"

pd "github.com/tikv/pd/client/clients/router"
)

Expand Down
7 changes: 4 additions & 3 deletions client/inner_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@ import (
"sync"
"time"

"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/pingcap/errors"
"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/pingcap/log"

cb "github.com/tikv/pd/client/circuitbreaker"
"github.com/tikv/pd/client/clients/tso"
"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/metrics"
"github.com/tikv/pd/client/opt"
sd "github.com/tikv/pd/client/servicediscovery"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/status"
)

const (
Expand Down
2 changes: 2 additions & 0 deletions client/keyspace_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ import (
"time"

"github.com/opentracing/opentracing-go"

"github.com/pingcap/errors"
"github.com/pingcap/kvproto/pkg/keyspacepb"

"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/metrics"
)
Expand Down
4 changes: 3 additions & 1 deletion client/meta_storage_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ import (
"time"

"github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus"

"github.com/pingcap/errors"
"github.com/pingcap/failpoint"
"github.com/pingcap/kvproto/pkg/meta_storagepb"
"github.com/prometheus/client_golang/prometheus"

"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/client/metrics"
"github.com/tikv/pd/client/opt"
Expand Down
7 changes: 4 additions & 3 deletions client/opt/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ import (
"sync/atomic"
"time"

cb "github.com/tikv/pd/client/circuitbreaker"
"github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc"

"github.com/pingcap/errors"
"github.com/prometheus/client_golang/prometheus"

cb "github.com/tikv/pd/client/circuitbreaker"
"github.com/tikv/pd/client/pkg/retry"
"google.golang.org/grpc"
)

const (
Expand Down
1 change: 1 addition & 0 deletions client/opt/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"time"

"github.com/stretchr/testify/require"

"github.com/tikv/pd/client/pkg/utils/testutil"
)

Expand Down
Loading
Loading