diff --git a/.golangci.yml b/.golangci.yml index f33f66e680c..0775a111395 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -3,6 +3,7 @@ linters: - unconvert - unparam - revive + - depguard linters-settings: revive: @@ -28,3 +29,14 @@ linters-settings: - name: superfluous-else - name: modifies-parameter - name: unreachable-code + + depguard: + list-type: blacklist + include-go-root: false + packages: + - log + - github.com/pingcap/errors + packages-with-error-message: + # specify an error message to output when a blacklisted package is used + - log: "logging is allowed only by pingcap/log" + - github.com/juju/errors: "error handling is allowed only by pingcap/errors" diff --git a/cdc/puller/frontier/list.go b/cdc/puller/frontier/list.go index 2a14aeafff8..249127d6bfb 100644 --- a/cdc/puller/frontier/list.go +++ b/cdc/puller/frontier/list.go @@ -16,11 +16,12 @@ package frontier import ( "bytes" "fmt" - "log" "math" "strings" _ "unsafe" // required by go:linkname + + "github.com/pingcap/log" ) const ( diff --git a/cdc/scheduler/util/table_set.go b/cdc/scheduler/util/table_set.go index a1eeb3a376e..963f7a30b1d 100644 --- a/cdc/scheduler/util/table_set.go +++ b/cdc/scheduler/util/table_set.go @@ -14,8 +14,7 @@ package util import ( - "log" - + "github.com/pingcap/log" "github.com/pingcap/ticdc/cdc/model" "go.uber.org/zap" ) diff --git a/cdc/sink/codec/canal.go b/cdc/sink/codec/canal.go index 873bd3eb596..91a151a1131 100644 --- a/cdc/sink/codec/canal.go +++ b/cdc/sink/codec/canal.go @@ -16,12 +16,12 @@ package codec import ( "context" "fmt" - "log" "strconv" "strings" "github.com/golang/protobuf/proto" // nolint:staticcheck "github.com/pingcap/errors" + "github.com/pingcap/log" "github.com/pingcap/ticdc/cdc/model" "github.com/pingcap/ticdc/pkg/config" cerror "github.com/pingcap/ticdc/pkg/errors" diff --git a/cdc/sink/common/flow_control.go b/cdc/sink/common/flow_control.go index 47ad19fc6b7..a008d58b25a 100644 --- a/cdc/sink/common/flow_control.go +++ b/cdc/sink/common/flow_control.go @@ -14,12 +14,12 @@ package common import ( - "log" "sync" "sync/atomic" "github.com/edwingeng/deque" "github.com/pingcap/errors" + "github.com/pingcap/log" cerrors "github.com/pingcap/ticdc/pkg/errors" "go.uber.org/zap" ) diff --git a/pkg/context/context.go b/pkg/context/context.go index c8eff1f5dd7..3adf20d9cab 100644 --- a/pkg/context/context.go +++ b/pkg/context/context.go @@ -15,9 +15,9 @@ package context import ( "context" - "log" "time" + "github.com/pingcap/log" "github.com/pingcap/ticdc/cdc/kv" "github.com/pingcap/ticdc/cdc/model" "github.com/pingcap/ticdc/cdc/processor/pipeline/system" diff --git a/pkg/etcd/etcdkey.go b/pkg/etcd/etcdkey.go index bf47a210a30..8b91dc36921 100644 --- a/pkg/etcd/etcdkey.go +++ b/pkg/etcd/etcdkey.go @@ -14,9 +14,9 @@ package etcd import ( - "log" "strings" + "github.com/pingcap/log" cerror "github.com/pingcap/ticdc/pkg/errors" ) diff --git a/pkg/orchestrator/util/key_utils.go b/pkg/orchestrator/util/key_utils.go index e9b68ca491c..008c8ae9705 100644 --- a/pkg/orchestrator/util/key_utils.go +++ b/pkg/orchestrator/util/key_utils.go @@ -14,8 +14,9 @@ package util import ( - "log" "strings" + + "github.com/pingcap/log" ) // EtcdKey represents a complete key in Etcd. diff --git a/tests/mq_protocol_tests/cases/case_date_time.go b/tests/mq_protocol_tests/cases/case_date_time.go index 6df14585238..74f5f64523f 100644 --- a/tests/mq_protocol_tests/cases/case_date_time.go +++ b/tests/mq_protocol_tests/cases/case_date_time.go @@ -15,9 +15,9 @@ package cases import ( "errors" - "log" "time" + "github.com/pingcap/log" "github.com/pingcap/ticdc/tests/mq_protocol_tests/framework" "github.com/pingcap/ticdc/tests/mq_protocol_tests/framework/avro" "github.com/pingcap/ticdc/tests/mq_protocol_tests/framework/canal"