Skip to content

Commit

Permalink
pkg/server: using the correct errors import package (#56423)
Browse files Browse the repository at this point in the history
  • Loading branch information
zimulala authored Sep 30, 2024
1 parent 8e33fcd commit 74034d4
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ require (
github.com/cheggaaa/pb/v3 v3.0.8
github.com/cheynewallace/tabby v1.1.1
github.com/cloudfoundry/gosigar v1.3.6
github.com/cockroachdb/errors v1.11.1
github.com/cockroachdb/pebble v1.1.0
github.com/coocood/freecache v1.2.1
github.com/coreos/go-semver v0.3.1
Expand Down Expand Up @@ -155,6 +154,7 @@ require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/apache/arrow/go/v12 v12.0.1 // indirect
github.com/cockroachdb/errors v1.11.1 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/goccy/go-reflect v1.2.0 // indirect
Expand Down
3 changes: 1 addition & 2 deletions pkg/server/tests/servertestkit/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ go_library(
"//pkg/util/cpuprofile",
"//pkg/util/topsql/collector/mock",
"//pkg/util/topsql/state",
"@com_github_cockroachdb_errors//:errors",
"@com_github_pingcap_errors//:errors",
"@com_github_stretchr_testify//require",
"@io_opencensus_go//stats/view",
"@org_uber_go_zap//:zap",
],
)
5 changes: 2 additions & 3 deletions pkg/server/tests/servertestkit/testkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"testing"
"time"

"github.com/cockroachdb/errors"
"github.com/pingcap/errors"
"github.com/pingcap/tidb/pkg/config"
"github.com/pingcap/tidb/pkg/domain"
"github.com/pingcap/tidb/pkg/kv"
Expand All @@ -37,7 +37,6 @@ import (
topsqlstate "github.com/pingcap/tidb/pkg/util/topsql/state"
"github.com/stretchr/testify/require"
"go.opencensus.io/stats/view"
"go.uber.org/zap"
)

// TidbTestSuite is a test suite for tidb
Expand Down Expand Up @@ -79,7 +78,7 @@ func parseDuration(lease string) (time.Duration, error) {
dur, err = time.ParseDuration(lease + "s")
}
if err != nil || dur < 0 {
return 0, errors.Newf("invalid lease duration", zap.String("lease", lease))
return 0, errors.Errorf("invalid lease duration: %s", lease)
}
return dur, nil
}
Expand Down
1 change: 0 additions & 1 deletion pkg/util/cgroup/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ go_library(
importpath = "github.com/pingcap/tidb/pkg/util/cgroup",
visibility = ["//visibility:public"],
deps = [
"@com_github_cockroachdb_errors//:errors",
"@com_github_pingcap_errors//:errors",
"@com_github_pingcap_log//:log",
"@org_uber_go_zap//:zap",
Expand Down
6 changes: 3 additions & 3 deletions pkg/util/cgroup/cgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"strconv"
"strings"

"github.com/cockroachdb/errors"
"github.com/pingcap/errors"
"github.com/pingcap/log"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -136,7 +136,7 @@ func readFile(filepath string) (res []byte, err error) {
return nil, err
}
defer func() {
err = errors.CombineErrors(err, f.Close())
err = errors.Join(err, f.Close())
}()
res, err = io.ReadAll(f)
return res, err
Expand Down Expand Up @@ -404,7 +404,7 @@ func detectCPUUsageInV2(cRoot string) (stime, utime uint64, err error) {
return 0, 0, errors.Wrapf(err, "can't read cpu usage from cgroup v2 at %s", statFilePath)
}
defer func() {
err = errors.CombineErrors(err, stat.Close())
err = errors.Join(err, stat.Close())
}()

scanner := bufio.NewScanner(stat)
Expand Down

0 comments on commit 74034d4

Please sign in to comment.