From 01e0b3d8111c577d508c4a3953b100576aff8e8f Mon Sep 17 00:00:00 2001 From: lhy1024 Date: Thu, 1 Aug 2024 11:46:20 +0800 Subject: [PATCH 1/2] update go to 1.21 (#1709) --- .github/workflows/build.yaml | 4 +- .github/workflows/release.yaml | 2 +- .github/workflows/test.yaml | 6 +- .github/workflows/upload-e2e-snapshots.yaml | 2 +- .golangci.yml | 10 +- CONTRIBUTING.md | 2 +- dockerfiles/alpine316.Dockerfile | 2 +- dockerfiles/centos7.Dockerfile | 2 +- go.mod | 2 +- go.sum | 13 +++ pkg/apiserver/apiserver.go | 2 +- pkg/apiserver/conprof/service.go | 16 +-- pkg/apiserver/diagnose/report.go | 18 ++-- pkg/apiserver/diagnose/report_test.go | 24 ++--- pkg/apiserver/profiling/profile.go | 2 +- pkg/apiserver/profiling/protobuf_to_svg.go | 16 +-- pkg/apiserver/statement/config_test.go | 36 +++---- pkg/apiserver/statement/models.go | 2 +- pkg/apiserver/topsql/service.go | 4 +- pkg/apiserver/user/auth.go | 10 +- pkg/apiserver/user/verify_sql_user_test.go | 20 ++-- pkg/apiserver/utils/gorm_test.go | 16 +-- pkg/apiserver/utils/jwt.go | 2 +- pkg/config/dynamic_config_manager.go | 2 +- pkg/keyvisual/decorator/decorator.go | 4 +- pkg/keyvisual/decorator/decorator_test.go | 4 +- pkg/keyvisual/decorator/separator.go | 2 +- pkg/keyvisual/decorator/tidb.go | 2 +- pkg/keyvisual/decorator/tidb_test.go | 4 +- pkg/keyvisual/input/file.go | 2 +- pkg/keyvisual/matrix/average.go | 4 +- pkg/keyvisual/matrix/average_test.go | 4 +- pkg/keyvisual/matrix/axis_test.go | 8 +- pkg/keyvisual/matrix/distance_test.go | 4 +- pkg/keyvisual/matrix/key.go | 6 +- pkg/keyvisual/matrix/key_test.go | 4 +- pkg/keyvisual/matrix/matrix_test.go | 6 +- pkg/keyvisual/matrix/plane_test.go | 4 +- pkg/keyvisual/matrix/util_test.go | 10 +- pkg/keyvisual/region/utils.go | 20 +--- pkg/keyvisual/service.go | 4 +- pkg/keyvisual/storage/model_test.go | 64 +++++------ pkg/keyvisual/storage/region_test.go | 6 +- pkg/keyvisual/storage/stat_test.go | 6 +- pkg/tidb/model/codec_test.go | 28 ++--- pkg/tidb/proxy.go | 8 +- pkg/tidb/proxy_test.go | 4 +- pkg/uiserver/uiserver.go | 2 +- pkg/utils/sys_schema.go | 2 +- pkg/utils/topology/scheduling.go | 2 +- pkg/utils/topology/tiproxy.go | 2 +- pkg/utils/topology/tso.go | 2 +- scripts/go.mod | 40 +++---- scripts/go.sum | 114 +++++++++++++------- scripts/lint.sh | 2 +- tests/integration/diagnose_report_test.go | 8 +- util/client/httpclient/response.go | 2 +- util/client/httpclient/response_test.go | 32 +++--- util/gormutil/virtualview/schema.go | 2 +- util/proxy/proxy.go | 8 +- util/proxy/proxy_test.go | 2 +- util/rest/error_test.go | 2 +- util/rest/fileswap/server.go | 2 +- util/testutil/http_server.go | 6 +- util/topo/mock_TopologyProvider.go | 74 ++++++++++--- 65 files changed, 409 insertions(+), 318 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f938539a47..c3ab89b373 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -18,7 +18,7 @@ jobs: uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: "1.18" + go-version: "1.21" - name: Load go module cache uses: actions/cache@v3 with: @@ -61,7 +61,7 @@ jobs: cache-dependency-path: "ui/pnpm-lock.yaml" - uses: actions/setup-go@v3 with: - go-version: "1.18" + go-version: "1.21" - name: Load go module cache uses: actions/cache@v3 with: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 03995c8d09..6182f7f9a2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -26,7 +26,7 @@ jobs: cache-dependency-path: "ui/pnpm-lock.yaml" - uses: actions/setup-go@v3 with: - go-version: "1.18" + go-version: "1.21" - name: Load go module cache uses: actions/cache@v3 with: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index e267a875eb..6b820c0946 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -19,7 +19,7 @@ jobs: uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: "1.18" + go-version: "1.21" - name: Load go module cache uses: actions/cache@v3 with: @@ -53,7 +53,7 @@ jobs: uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: "1.18" + go-version: "1.21" - name: Load go module cache uses: actions/cache@v3 with: @@ -124,7 +124,7 @@ jobs: # ${{ runner.os }}-cypress- # - uses: actions/setup-go@v3 # with: - # go-version: "1.18" + # go-version: "1.21" # - name: Load go module cache # uses: actions/cache@v3 # with: diff --git a/.github/workflows/upload-e2e-snapshots.yaml b/.github/workflows/upload-e2e-snapshots.yaml index 4ee92fd1a5..30935bb7db 100644 --- a/.github/workflows/upload-e2e-snapshots.yaml +++ b/.github/workflows/upload-e2e-snapshots.yaml @@ -45,7 +45,7 @@ jobs: cache-dependency-path: "ui/pnpm-lock.yaml" - uses: actions/setup-go@v3 with: - go-version: "1.18" + go-version: "1.21" - name: Load go module cache uses: actions/cache@v3 with: diff --git a/.golangci.yml b/.golangci.yml index 6c46b4f306..2beb83021d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,8 +1,4 @@ run: - skip-dirs: - - swaggerspec - - pkg/uiserver - - ui timeout: 2m issues: @@ -25,12 +21,16 @@ issues: - text: "G112:" linters: - gosec + exclude-dirs: + - swaggerspec + - pkg/uiserver + - ui linters: enable: # Additionally enable some checkers - asciicheck - - depguard + # - depguard - dogsled - durationcheck - errorlint diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7378249ea6..4f076d64f1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -44,7 +44,7 @@ The followings are required for developing TiDB Dashboard: - git - Version control - make - Build tool (run common workflows) -- [Golang 1.19+](https://golang.org/) - To compile the server. +- [Golang 1.21+](https://golang.org/) - To compile the server. - [Node.js 18](https://nodejs.org/) - To compile the front-end. - [PNPM 8](https://pnpm.io/) - To manage front-end dependencies. - [Java 8+](https://www.java.com/ES/download/) - To generate JavaScript API client by OpenAPI specification. diff --git a/dockerfiles/alpine316.Dockerfile b/dockerfiles/alpine316.Dockerfile index 2927d2d848..d041f16ca9 100644 --- a/dockerfiles/alpine316.Dockerfile +++ b/dockerfiles/alpine316.Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.18-alpine3.16 as builder +FROM golang:1.21-alpine3.16 as builder RUN apk add --no-cache \ make \ diff --git a/dockerfiles/centos7.Dockerfile b/dockerfiles/centos7.Dockerfile index f4584e0716..941b20f4de 100644 --- a/dockerfiles/centos7.Dockerfile +++ b/dockerfiles/centos7.Dockerfile @@ -6,7 +6,7 @@ RUN yum -y groupinstall "Development Tools" # Install golang. ENV PATH /usr/local/go/bin:$PATH RUN export ARCH=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) && \ - export GO_VERSION=1.19.5 && \ + export GO_VERSION=1.21.12 && \ curl -OL https://golang.org/dl/go$GO_VERSION.linux-$ARCH.tar.gz && \ tar -C /usr/local/ -xzf go$GO_VERSION.linux-$ARCH.tar.gz && \ rm -f go$GO_VERSION.linux-$ARCH.tar.gz diff --git a/go.mod b/go.mod index 71d5619bee..ecc0eb1c72 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/pingcap/tidb-dashboard -go 1.18 +go 1.21 require ( github.com/DATA-DOG/go-sqlmock v1.5.0 diff --git a/go.sum b/go.sum index ae5e132fc4..3756d94c1e 100644 --- a/go.sum +++ b/go.sum @@ -77,6 +77,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/denisenkom/go-mssqldb v0.11.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/denisenkom/go-mssqldb v0.12.0 h1:VtrkII767ttSPNRfFekePK3sctr+joXgO58stqQbtUA= +github.com/denisenkom/go-mssqldb v0.12.0/go.mod h1:iiK0YP1ZeepvmBQk/QpLEhhTNJgfzrpArPY/aFvc9yU= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4 h1:qk/FSDDxo05wdJH28W+p5yivv7LuLYLRXPPD8KQCtZs= @@ -116,6 +117,7 @@ github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyr github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= @@ -145,7 +147,9 @@ github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfE github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA= +github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A= +github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= @@ -200,6 +204,7 @@ github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s= github.com/jackc/pgconn v1.5.0/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI= github.com/jackc/pgconn v1.13.0 h1:3L1XMNV2Zvca/8BYhzcRFS70Lr0WlDg16Di6SFGAbys= +github.com/jackc/pgconn v1.13.0/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI= github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= @@ -213,13 +218,16 @@ github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvW github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= github.com/jackc/pgproto3/v2 v2.0.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgproto3/v2 v2.3.1 h1:nwj7qwf0S+Q7ISFfBndqeLwSwxs+4DPsbRFjECT1Y4Y= +github.com/jackc/pgproto3/v2 v2.3.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgservicefile v0.0.0-20200307190119-3430c5407db8/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= +github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= github.com/jackc/pgtype v1.3.0/go.mod h1:b0JqxHvPmljG+HQ5IsvQ0yqeSi4nGcDTVjFoiLDb0Ik= github.com/jackc/pgtype v1.12.0 h1:Dlq8Qvcch7kiehm8wPGIW0W3KsCCHJnRacKW0UM8n5w= +github.com/jackc/pgtype v1.12.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= github.com/jackc/pgx v3.6.2+incompatible h1:2zP5OD7kiyR3xzRYMhOcXVvkDZsImVXfj+yIyTQf3/o= github.com/jackc/pgx v3.6.2+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I= github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= @@ -227,6 +235,7 @@ github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9 github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= github.com/jackc/pgx/v4 v4.6.0/go.mod h1:vPh43ZzxijXUVJ+t/EmXBtFmbFVO72cuneCT9oAlxAg= github.com/jackc/pgx/v4 v4.17.2 h1:0Ut0rpeKwvIVbMQ1KbMBU4h6wxehBI535LK6Flheh8E= +github.com/jackc/pgx/v4 v4.17.2/go.mod h1:lcxIZN44yMIrWI78a5CpucdD14hX0SBDbNRvjDBItsw= github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= @@ -306,6 +315,7 @@ github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/microsoft/go-mssqldb v0.17.0 h1:Fto83dMZPnYv1Zwx5vHHxpNraeEaUlQ/hhHLgZiaenE= +github.com/microsoft/go-mssqldb v0.17.0/go.mod h1:OkoNGhGEs8EZqchVTtochlXruEhEOaO4S0d2sB5aeGQ= github.com/minio/sio v0.3.0 h1:syEFBewzOMOYVzSTFpp1MqpSZk8rUNbz8VIIc+PNzus= github.com/minio/sio v0.3.0/go.mod h1:8b0yPp2avGThviy/+OCJBI6OMpvxoUuiLvE6F1lebhw= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -514,6 +524,7 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -655,9 +666,11 @@ gorm.io/datatypes v1.1.0/go.mod h1:SH2K9R+2RMjuX1CkCONrPwoe9JzVv2hkQvEu4bXGojE= gorm.io/driver/mysql v1.4.5 h1:u1lytId4+o9dDaNcPCFzNv7h6wvmc92UjNk3z8enSBU= gorm.io/driver/mysql v1.4.5/go.mod h1:SxzItlnT1cb6e1e4ZRpgJN2VYtcqJgqnHxWr4wsP8oc= gorm.io/driver/postgres v1.4.5 h1:mTeXTTtHAgnS9PgmhN2YeUbazYpLhUI1doLnw42XUZc= +gorm.io/driver/postgres v1.4.5/go.mod h1:GKNQYSJ14qvWkvPwXljMGehpKrhlDNsqYRr5HnYGncg= gorm.io/driver/sqlite v1.4.3 h1:HBBcZSDnWi5BW3B3rwvVTc510KGkBkexlOg0QrmLUuU= gorm.io/driver/sqlite v1.4.3/go.mod h1:0Aq3iPO+v9ZKbcdiz8gLWRw5VOPcBOPUQJFLq5e2ecI= gorm.io/driver/sqlserver v1.4.1 h1:t4r4r6Jam5E6ejqP7N82qAJIJAht27EGT41HyPfXRw0= +gorm.io/driver/sqlserver v1.4.1/go.mod h1:DJ4P+MeZbc5rvY58PnmN1Lnyvb5gw5NPzGshHDnJLig= gorm.io/gorm v1.21.9/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0= gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA= diff --git a/pkg/apiserver/apiserver.go b/pkg/apiserver/apiserver.go index 9186d06f0f..4b1d0dfb55 100644 --- a/pkg/apiserver/apiserver.go +++ b/pkg/apiserver/apiserver.go @@ -282,7 +282,7 @@ func newAPIHandlerEngine() (apiHandlerEngine *gin.Engine, endpoint *gin.RouterGr return } -var StoppedHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { +var StoppedHandler = http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusNotFound) _, _ = io.WriteString(w, "Dashboard is not started.\n") }) diff --git a/pkg/apiserver/conprof/service.go b/pkg/apiserver/conprof/service.go index efb0f560d6..551f3acd49 100644 --- a/pkg/apiserver/conprof/service.go +++ b/pkg/apiserver/conprof/service.go @@ -87,7 +87,7 @@ type NgMonitoringConfig struct { // @Security JwtAuth // @Failure 401 {object} rest.ErrorResponse // @Failure 500 {object} rest.ErrorResponse -func (s *Service) ConprofConfig(c *gin.Context) { +func (s *Service) ConprofConfig(_ *gin.Context) { // dummy, for generate openapi } @@ -98,7 +98,7 @@ func (s *Service) ConprofConfig(c *gin.Context) { // @Success 200 {string} string "ok" // @Failure 401 {object} rest.ErrorResponse // @Failure 500 {object} rest.ErrorResponse -func (s *Service) UpdateConprofConfig(c *gin.Context) { +func (s *Service) UpdateConprofConfig(_ *gin.Context) { // dummy, for generate openapi } @@ -115,7 +115,7 @@ type Component struct { // @Security JwtAuth // @Failure 401 {object} rest.ErrorResponse // @Failure 500 {object} rest.ErrorResponse -func (s *Service) ConprofComponents(c *gin.Context) { +func (s *Service) ConprofComponents(_ *gin.Context) { // dummy, for generate openapi } @@ -130,7 +130,7 @@ type EstimateSizeRes struct { // @Success 200 {object} EstimateSizeRes // @Failure 401 {object} rest.ErrorResponse // @Failure 500 {object} rest.ErrorResponse -func (s *Service) EstimateSize(c *gin.Context) { +func (s *Service) EstimateSize(_ *gin.Context) { // dummy, for generate openapi } @@ -180,7 +180,7 @@ type Target struct { // @Success 200 {array} GroupProfiles // @Failure 401 {object} rest.ErrorResponse // @Failure 500 {object} rest.ErrorResponse -func (s *Service) ConprofGroupProfiles(c *gin.Context) { +func (s *Service) ConprofGroupProfiles(_ *gin.Context) { // dummy, for generate openapi } @@ -191,7 +191,7 @@ func (s *Service) ConprofGroupProfiles(c *gin.Context) { // @Success 200 {object} GroupProfileDetail // @Failure 401 {object} rest.ErrorResponse // @Failure 500 {object} rest.ErrorResponse -func (s *Service) ConprofGroupProfileDetail(c *gin.Context) { +func (s *Service) ConprofGroupProfileDetail(_ *gin.Context) { // dummy, for generate openapi } @@ -219,7 +219,7 @@ func (s *Service) GenConprofActionToken(c *gin.Context) { // @Produce application/x-gzip // @Failure 401 {object} rest.ErrorResponse // @Failure 500 {object} rest.ErrorResponse -func (s *Service) ConprofDownload(c *gin.Context) { +func (s *Service) ConprofDownload(_ *gin.Context) { // dummy, for generate openapi } @@ -248,6 +248,6 @@ type ViewSingleProfileReq struct { // @Produce html // @Failure 401 {object} rest.ErrorResponse // @Failure 500 {object} rest.ErrorResponse -func (s *Service) ConprofViewProfile(c *gin.Context) { +func (s *Service) ConprofViewProfile(_ *gin.Context) { // dummy, for generate openapi } diff --git a/pkg/apiserver/diagnose/report.go b/pkg/apiserver/diagnose/report.go index 70207574e2..06c161eeda 100644 --- a/pkg/apiserver/diagnose/report.go +++ b/pkg/apiserver/diagnose/report.go @@ -302,7 +302,7 @@ func GenerateReportError(errRows []TableRowDef) *TableDef { } } -func GetHeaderTimeTable(startTime, endTime string, db *gorm.DB) (TableDef, error) { +func GetHeaderTimeTable(startTime, endTime string, _ *gorm.DB) (TableDef, error) { return TableDef{ Category: []string{CategoryHeader}, Title: "report_time_range", @@ -716,7 +716,7 @@ func GetTiDBDDLOwner(startTime, endTime string, db *gorm.DB) (TableDef, error) { return table, nil } -func GetPDConfigInfo(startTime, endTime string, db *gorm.DB) (TableDef, error) { +func GetPDConfigInfo(startTime, _ string, db *gorm.DB) (TableDef, error) { table := TableDef{ Category: []string{CategoryConfig}, Title: "scheduler_initial_config", @@ -761,7 +761,7 @@ func GetPDConfigChangeInfo(startTime, endTime string, db *gorm.DB) (TableDef, er return table, nil } -func GetTiDBGCConfigInfo(startTime, endTime string, db *gorm.DB) (TableDef, error) { +func GetTiDBGCConfigInfo(startTime, _ string, db *gorm.DB) (TableDef, error) { table := TableDef{ Category: []string{CategoryConfig}, Title: "tidb_gc_initial_config", @@ -804,7 +804,7 @@ func GetTiDBGCConfigChangeInfo(startTime, endTime string, db *gorm.DB) (TableDef return table, nil } -func GetTiKVRocksDBConfigInfo(startTime, endTime string, db *gorm.DB) (TableDef, error) { +func GetTiKVRocksDBConfigInfo(startTime, _ string, db *gorm.DB) (TableDef, error) { table := TableDef{ Category: []string{CategoryConfig}, Title: "tikv_rocksdb_initial_config", @@ -885,7 +885,7 @@ func GetTiKVRocksDBConfigChangeInfo(startTime, endTime string, db *gorm.DB) (Tab return table, nil } -func GetTiKVRaftStoreConfigInfo(startTime, endTime string, db *gorm.DB) (TableDef, error) { +func GetTiKVRaftStoreConfigInfo(startTime, _ string, db *gorm.DB) (TableDef, error) { table := TableDef{ Category: []string{CategoryConfig}, Title: "tikv_raftstore_initial_config", @@ -1479,7 +1479,7 @@ func GetTiKVErrorTable(startTime, endTime string, db *gorm.DB) (TableDef, error) return table, nil } -func GetTiDBCurrentConfig(startTime, endTime string, db *gorm.DB) (TableDef, error) { +func GetTiDBCurrentConfig(_, _ string, db *gorm.DB) (TableDef, error) { sql := "select `key`,`value` from information_schema.CLUSTER_CONFIG where type='tidb' group by `key`,`value` order by `key`;" table := TableDef{ Category: []string{CategoryConfig}, @@ -1495,7 +1495,7 @@ func GetTiDBCurrentConfig(startTime, endTime string, db *gorm.DB) (TableDef, err return table, nil } -func GetPDCurrentConfig(startTime, endTime string, db *gorm.DB) (TableDef, error) { +func GetPDCurrentConfig(_, _ string, db *gorm.DB) (TableDef, error) { sql := "select `key`,`value` from information_schema.CLUSTER_CONFIG where type='pd' group by `key`,`value` order by `key`;" table := TableDef{ Category: []string{CategoryConfig}, @@ -1511,7 +1511,7 @@ func GetPDCurrentConfig(startTime, endTime string, db *gorm.DB) (TableDef, error return table, nil } -func GetTiKVCurrentConfig(startTime, endTime string, db *gorm.DB) (TableDef, error) { +func GetTiKVCurrentConfig(_, _ string, db *gorm.DB) (TableDef, error) { sql := "select `key`,`value` from information_schema.CLUSTER_CONFIG where type='tikv' group by `key`,`value` order by `key`;" table := TableDef{ Category: []string{CategoryConfig}, @@ -2038,7 +2038,7 @@ func GetPDEtcdStatusTable(startTime, endTime string, db *gorm.DB) (TableDef, err return table, nil } -func GetClusterInfoTable(startTime, endTime string, db *gorm.DB) (TableDef, error) { +func GetClusterInfoTable(_, _ string, db *gorm.DB) (TableDef, error) { sql := "select * from information_schema.cluster_info order by type,start_time desc" table := TableDef{ Category: []string{CategoryHeader}, diff --git a/pkg/apiserver/diagnose/report_test.go b/pkg/apiserver/diagnose/report_test.go index 28ba9754a4..9d97360e3c 100644 --- a/pkg/apiserver/diagnose/report_test.go +++ b/pkg/apiserver/diagnose/report_test.go @@ -5,19 +5,19 @@ package diagnose import ( "testing" - . "github.com/pingcap/check" + "github.com/pingcap/check" ) func TestT(t *testing.T) { - CustomVerboseFlag = true - TestingT(t) + check.CustomVerboseFlag = true + check.TestingT(t) } -var _ = Suite(&testReportSuite{}) +var _ = check.Suite(&testReportSuite{}) type testReportSuite struct{} -func (t *testReportSuite) TestCompareTable(c *C) { +func (t *testReportSuite) TestCompareTable(c *check.C) { table1 := TableDef{ Category: []string{"header"}, Title: "test", @@ -89,19 +89,19 @@ func (t *testReportSuite) TestCompareTable(c *C) { t1.Rows = cas.rows1 t2.Rows = cas.rows2 t, err := compareTable(&t1, &t2, dr) - c.Assert(err, IsNil) - c.Assert(len(t.Rows), Equals, len(cas.out)) + c.Assert(err, check.IsNil) + c.Assert(len(t.Rows), check.Equals, len(cas.out)) for i, row := range t.Rows { - c.Assert(row.Values, DeepEquals, cas.out[i].Values) - c.Assert(len(row.SubValues), Equals, len(cas.out[i].SubValues)) + c.Assert(row.Values, check.DeepEquals, cas.out[i].Values) + c.Assert(len(row.SubValues), check.Equals, len(cas.out[i].SubValues)) for j, subRow := range cas.out[i].SubValues { - c.Assert(subRow, DeepEquals, row.SubValues[j]) + c.Assert(subRow, check.DeepEquals, row.SubValues[j]) } } } } -func (t *testReportSuite) TestRoundFloatString(c *C) { +func (t *testReportSuite) TestRoundFloatString(c *check.C) { cases := []struct { in string out string @@ -123,6 +123,6 @@ func (t *testReportSuite) TestRoundFloatString(c *C) { } for _, cas := range cases { result := RoundFloatString(cas.in) - c.Assert(result, Equals, cas.out) + c.Assert(result, check.Equals, cas.out) } } diff --git a/pkg/apiserver/profiling/profile.go b/pkg/apiserver/profiling/profile.go index 17fe586202..4c87d1141d 100644 --- a/pkg/apiserver/profiling/profile.go +++ b/pkg/apiserver/profiling/profile.go @@ -8,7 +8,7 @@ import ( "github.com/pingcap/tidb-dashboard/pkg/apiserver/model" ) -func profileAndWritePprof(ctx context.Context, fts *fetchers, target *model.RequestTargetNode, fileNameWithoutExt string, profileDurationSecs uint, profilingType TaskProfilingType) (string, TaskRawDataType, error) { +func profileAndWritePprof(_ context.Context, fts *fetchers, target *model.RequestTargetNode, fileNameWithoutExt string, profileDurationSecs uint, profilingType TaskProfilingType) (string, TaskRawDataType, error) { switch target.Kind { case model.NodeKindTiKV: // TiKV only supports CPU/heap Profiling diff --git a/pkg/apiserver/profiling/protobuf_to_svg.go b/pkg/apiserver/profiling/protobuf_to_svg.go index 5239cde62b..c7bcd6dd94 100644 --- a/pkg/apiserver/profiling/protobuf_to_svg.go +++ b/pkg/apiserver/profiling/protobuf_to_svg.go @@ -27,7 +27,7 @@ func convertProtobufToSVG(content []byte, task TaskModel) ([]byte, error) { return svgContent, nil } -func convertProtobufToDot(content []byte, task TaskModel) ([]byte, error) { +func convertProtobufToDot(content []byte, _ TaskModel) ([]byte, error) { args := []string{ "-dot", // prevent printing stdout @@ -75,7 +75,7 @@ type protobufToDotWriter struct { wc *writeCloser } -func (w *protobufToDotWriter) Open(name string) (io.WriteCloser, error) { +func (w *protobufToDotWriter) Open(_ string) (io.WriteCloser, error) { w.wc = &writeCloser{data: make([]byte, 0)} return w.wc, nil } @@ -98,7 +98,7 @@ type dotFetcher struct { data []byte } -func (f *dotFetcher) Fetch(src string, duration, timeout time.Duration) (*profile.Profile, string, error) { +func (f *dotFetcher) Fetch(_ string, _, _ time.Duration) (*profile.Profile, string, error) { profile, err := profile.ParseData(f.data) return profile, "", err } @@ -122,19 +122,19 @@ func (f *flagSet) Parse(usage func()) []string { return f.Args() } -func (f *flagSet) AddExtraUsage(eu string) {} +func (f *flagSet) AddExtraUsage(_ string) {} // blankPprofUI is used to eliminate the pprof logs. type blankPprofUI struct{} -func (b blankPprofUI) ReadLine(prompt string) (string, error) { +func (b blankPprofUI) ReadLine(_ string) (string, error) { panic("not support") } -func (b blankPprofUI) Print(i ...interface{}) { +func (b blankPprofUI) Print(_ ...interface{}) { } -func (b blankPprofUI) PrintErr(i ...interface{}) { +func (b blankPprofUI) PrintErr(_ ...interface{}) { } func (b blankPprofUI) IsTerminal() bool { @@ -145,5 +145,5 @@ func (b blankPprofUI) WantBrowser() bool { return false } -func (b blankPprofUI) SetAutoComplete(complete func(string) string) { +func (b blankPprofUI) SetAutoComplete(_ func(string) string) { } diff --git a/pkg/apiserver/statement/config_test.go b/pkg/apiserver/statement/config_test.go index 031c65ec51..6e830c149a 100644 --- a/pkg/apiserver/statement/config_test.go +++ b/pkg/apiserver/statement/config_test.go @@ -5,15 +5,15 @@ package statement import ( "testing" - . "github.com/pingcap/check" + "github.com/pingcap/check" ) func TestT(t *testing.T) { - CustomVerboseFlag = true - TestingT(t) + check.CustomVerboseFlag = true + check.TestingT(t) } -var _ = Suite(&testConfigSuite{}) +var _ = check.Suite(&testConfigSuite{}) type testConfigSuite struct{} @@ -22,14 +22,14 @@ type testConfig struct { RefreshInterval int `json:"refresh_interval" gorm:"column:tidb_stmt_summary_refresh_interval"` } -func (t *testConfigSuite) Test_buildGlobalConfigProjectionSelectSQL_struct_success(c *C) { +func (t *testConfigSuite) Test_buildGlobalConfigProjectionSelectSQL_struct_success(c *check.C) { testConfigStmt := "SELECT @@GLOBAL.tidb_enable_stmt_summary AS tidb_enable_stmt_summary, @@GLOBAL.tidb_stmt_summary_refresh_interval AS tidb_stmt_summary_refresh_interval" - c.Assert(buildGlobalConfigProjectionSelectSQL(testConfig{}), Equals, testConfigStmt) + c.Assert(buildGlobalConfigProjectionSelectSQL(testConfig{}), check.Equals, testConfigStmt) } -func (t *testConfigSuite) Test_buildGlobalConfigProjectionSelectSQL_ptr_success(c *C) { +func (t *testConfigSuite) Test_buildGlobalConfigProjectionSelectSQL_ptr_success(c *check.C) { testConfigStmt := "SELECT @@GLOBAL.tidb_enable_stmt_summary AS tidb_enable_stmt_summary, @@GLOBAL.tidb_stmt_summary_refresh_interval AS tidb_stmt_summary_refresh_interval" - c.Assert(buildGlobalConfigProjectionSelectSQL(&testConfig{}), Equals, testConfigStmt) + c.Assert(buildGlobalConfigProjectionSelectSQL(&testConfig{}), check.Equals, testConfigStmt) } type testConfig2 struct { @@ -37,27 +37,27 @@ type testConfig2 struct { RefreshInterval int `json:"refresh_interval"` } -func (t *testConfigSuite) Test_buildGlobalConfigProjectionSelectSQL_without_gorm_tag(c *C) { +func (t *testConfigSuite) Test_buildGlobalConfigProjectionSelectSQL_without_gorm_tag(c *check.C) { testConfigStmt := "SELECT @@GLOBAL.tidb_enable_stmt_summary AS tidb_enable_stmt_summary" - c.Assert(buildGlobalConfigProjectionSelectSQL(&testConfig2{}), Equals, testConfigStmt) + c.Assert(buildGlobalConfigProjectionSelectSQL(&testConfig2{}), check.Equals, testConfigStmt) } -func (t *testConfigSuite) Test_buildGlobalConfigNamedArgsUpdateSQL_struct_success(c *C) { +func (t *testConfigSuite) Test_buildGlobalConfigNamedArgsUpdateSQL_struct_success(c *check.C) { testConfigStmt := "SET @@GLOBAL.tidb_enable_stmt_summary = @Enable, @@GLOBAL.tidb_stmt_summary_refresh_interval = @RefreshInterval" - c.Assert(buildGlobalConfigNamedArgsUpdateSQL(testConfig{Enable: true, RefreshInterval: 1800}), Equals, testConfigStmt) + c.Assert(buildGlobalConfigNamedArgsUpdateSQL(testConfig{Enable: true, RefreshInterval: 1800}), check.Equals, testConfigStmt) } -func (t *testConfigSuite) Test_buildGlobalConfigNamedArgsUpdateSQL_ptr_success(c *C) { +func (t *testConfigSuite) Test_buildGlobalConfigNamedArgsUpdateSQL_ptr_success(c *check.C) { testConfigStmt := "SET @@GLOBAL.tidb_enable_stmt_summary = @Enable, @@GLOBAL.tidb_stmt_summary_refresh_interval = @RefreshInterval" - c.Assert(buildGlobalConfigNamedArgsUpdateSQL(&testConfig{Enable: true, RefreshInterval: 1800}), Equals, testConfigStmt) + c.Assert(buildGlobalConfigNamedArgsUpdateSQL(&testConfig{Enable: true, RefreshInterval: 1800}), check.Equals, testConfigStmt) } -func (t *testConfigSuite) Test_buildGlobalConfigNamedArgsUpdateSQL_without_gorm_tag(c *C) { +func (t *testConfigSuite) Test_buildGlobalConfigNamedArgsUpdateSQL_without_gorm_tag(c *check.C) { testConfigStmt := "SET @@GLOBAL.tidb_enable_stmt_summary = @Enable" - c.Assert(buildGlobalConfigNamedArgsUpdateSQL(&testConfig2{Enable: true, RefreshInterval: 1800}), Equals, testConfigStmt) + c.Assert(buildGlobalConfigNamedArgsUpdateSQL(&testConfig2{Enable: true, RefreshInterval: 1800}), check.Equals, testConfigStmt) } -func (t *testConfigSuite) Test_buildGlobalConfigNamedArgsUpdateSQL_extract_fields(c *C) { +func (t *testConfigSuite) Test_buildGlobalConfigNamedArgsUpdateSQL_extract_fields(c *check.C) { testConfigStmt := "SET @@GLOBAL.tidb_enable_stmt_summary = @Enable" - c.Assert(buildGlobalConfigNamedArgsUpdateSQL(&testConfig{Enable: true, RefreshInterval: 1800}, "Enable"), Equals, testConfigStmt) + c.Assert(buildGlobalConfigNamedArgsUpdateSQL(&testConfig{Enable: true, RefreshInterval: 1800}, "Enable"), check.Equals, testConfigStmt) } diff --git a/pkg/apiserver/statement/models.go b/pkg/apiserver/statement/models.go index f08d075280..e21366da59 100644 --- a/pkg/apiserver/statement/models.go +++ b/pkg/apiserver/statement/models.go @@ -141,7 +141,7 @@ func (m *Model) checkSupportPlanBinding() bool { return true } -func (m *Model) AfterFind(db *gorm.DB) error { +func (m *Model) AfterFind(_ *gorm.DB) error { if len(m.AggTableNames) > 0 { m.RelatedSchemas = extractSchemasFromTableNames(m.AggTableNames) } diff --git a/pkg/apiserver/topsql/service.go b/pkg/apiserver/topsql/service.go index cbe1ed14cd..6636af309c 100644 --- a/pkg/apiserver/topsql/service.go +++ b/pkg/apiserver/topsql/service.go @@ -70,7 +70,7 @@ type InstanceItem struct { // @Success 200 {object} InstanceResponse "ok" // @Failure 401 {object} rest.ErrorResponse // @Failure 500 {object} rest.ErrorResponse -func (s *Service) GetInstance(c *gin.Context) { +func (s *Service) GetInstance(_ *gin.Context) { // dummy, for generate open api } @@ -117,7 +117,7 @@ type SummaryPlanItem struct { // @Success 200 {object} SummaryResponse "ok" // @Failure 401 {object} rest.ErrorResponse // @Failure 500 {object} rest.ErrorResponse -func (s *Service) GetSummary(c *gin.Context) { +func (s *Service) GetSummary(_ *gin.Context) { // dummy, for generate open api } diff --git a/pkg/apiserver/user/auth.go b/pkg/apiserver/user/auth.go index f944e50050..31250b5758 100644 --- a/pkg/apiserver/user/auth.go +++ b/pkg/apiserver/user/auth.go @@ -70,11 +70,11 @@ func (a BaseAuthenticator) IsEnabled() (bool, error) { return true, nil } -func (a BaseAuthenticator) ProcessSession(u *utils.SessionUser) bool { +func (a BaseAuthenticator) ProcessSession(_ *utils.SessionUser) bool { return true } -func (a BaseAuthenticator) SignOutInfo(u *utils.SessionUser, redirectURL string) (*SignOutInfo, error) { +func (a BaseAuthenticator) SignOutInfo(_ *utils.SessionUser, _ string) (*SignOutInfo, error) { return &SignOutInfo{}, nil } @@ -188,7 +188,7 @@ func NewAuthService(featureFlags *featureflag.Registry) *AuthService { return &user }, - Authorizator: func(data interface{}, c *gin.Context) bool { + Authorizator: func(data interface{}, _ *gin.Context) bool { // Ensure identity is valid if data == nil { return false @@ -211,10 +211,10 @@ func NewAuthService(featureFlags *featureflag.Registry) *AuthService { rest.Error(c, err) return err.Error() }, - Unauthorized: func(c *gin.Context, code int, message string) { + Unauthorized: func(c *gin.Context, code int, _ string) { c.Status(code) }, - LoginResponse: func(c *gin.Context, code int, token string, expire time.Time) { + LoginResponse: func(c *gin.Context, _ int, token string, expire time.Time) { c.JSON(http.StatusOK, TokenResponse{ Token: token, Expire: expire, diff --git a/pkg/apiserver/user/verify_sql_user_test.go b/pkg/apiserver/user/verify_sql_user_test.go index dfb311785f..349be33c40 100755 --- a/pkg/apiserver/user/verify_sql_user_test.go +++ b/pkg/apiserver/user/verify_sql_user_test.go @@ -5,19 +5,19 @@ package user import ( "testing" - . "github.com/pingcap/check" + "github.com/pingcap/check" ) func TestT(t *testing.T) { - CustomVerboseFlag = true - TestingT(t) + check.CustomVerboseFlag = true + check.TestingT(t) } -var _ = Suite(&testVerifySQLUserSuite{}) +var _ = check.Suite(&testVerifySQLUserSuite{}) type testVerifySQLUserSuite struct{} -func (t *testVerifySQLUserSuite) Test_parseUserGrants(c *C) { +func (t *testVerifySQLUserSuite) Test_parseUserGrants(c *check.C) { cases := []struct { desc string input []string @@ -70,11 +70,11 @@ func (t *testVerifySQLUserSuite) Test_parseUserGrants(c *C) { for i, v := range cases { actual := parseUserGrants(v.input) - c.Assert(actual, DeepEquals, v.expected, Commentf("parse %s (index: %d) failed", v.desc, i)) + c.Assert(actual, check.DeepEquals, v.expected, check.Commentf("parse %s (index: %d) failed", v.desc, i)) } } -func (t *testVerifySQLUserSuite) Test_checkDashboardPriv(c *C) { +func (t *testVerifySQLUserSuite) Test_checkDashboardPriv(c *check.C) { cases := []struct { desc string grants []string @@ -158,11 +158,11 @@ func (t *testVerifySQLUserSuite) Test_checkDashboardPriv(c *C) { grants[grant] = struct{}{} } actual := checkDashboardPriv(grants, v.enableSEM) - c.Assert(actual, DeepEquals, v.expected, Commentf("check %s (index: %d) failed", v.desc, i)) + c.Assert(actual, check.DeepEquals, v.expected, check.Commentf("check %s (index: %d) failed", v.desc, i)) } } -func (t *testVerifySQLUserSuite) Test_checkWriteablePriv(c *C) { +func (t *testVerifySQLUserSuite) Test_checkWriteablePriv(c *check.C) { cases := []struct { desc string grants []string @@ -216,6 +216,6 @@ func (t *testVerifySQLUserSuite) Test_checkWriteablePriv(c *C) { grants[grant] = struct{}{} } actual := checkWriteablePriv(grants) - c.Assert(actual, DeepEquals, v.expected, Commentf("check %s (index: %d) failed", v.desc, i)) + c.Assert(actual, check.DeepEquals, v.expected, check.Commentf("check %s (index: %d) failed", v.desc, i)) } } diff --git a/pkg/apiserver/utils/gorm_test.go b/pkg/apiserver/utils/gorm_test.go index 60a430c07c..e822699e1c 100644 --- a/pkg/apiserver/utils/gorm_test.go +++ b/pkg/apiserver/utils/gorm_test.go @@ -5,20 +5,20 @@ package utils import ( "testing" - . "github.com/pingcap/check" + "github.com/pingcap/check" ) func TestT(t *testing.T) { - CustomVerboseFlag = true - TestingT(t) + check.CustomVerboseFlag = true + check.TestingT(t) } -var _ = Suite(&testGormSuite{}) +var _ = check.Suite(&testGormSuite{}) type testGormSuite struct{} -func (t *testGormSuite) Test_GetGormColumnName(c *C) { - c.Assert(GetGormColumnName(`column:db`), Equals, `db`) - c.Assert(GetGormColumnName(`primaryKey;index`), Equals, ``) - c.Assert(GetGormColumnName(`column:db;primaryKey;index`), Equals, `db`) +func (t *testGormSuite) Test_GetGormColumnName(c *check.C) { + c.Assert(GetGormColumnName(`column:db`), check.Equals, `db`) + c.Assert(GetGormColumnName(`primaryKey;index`), check.Equals, ``) + c.Assert(GetGormColumnName(`column:db;primaryKey;index`), check.Equals, `db`) } diff --git a/pkg/apiserver/utils/jwt.go b/pkg/apiserver/utils/jwt.go index 0afc1cb362..7c06fd522f 100644 --- a/pkg/apiserver/utils/jwt.go +++ b/pkg/apiserver/utils/jwt.go @@ -46,7 +46,7 @@ func NewJWTStringWithExpire(issuer string, data string, expireIn time.Duration) // ParseJWTString parse the JWT string and return the raw data. func ParseJWTString(requiredIssuer string, tokenStr string) (string, error) { claims := &Claims{} - token, err := jwt.ParseWithClaims(tokenStr, claims, func(token *jwt.Token) (interface{}, error) { + token, err := jwt.ParseWithClaims(tokenStr, claims, func(_ *jwt.Token) (interface{}, error) { return hmacSampleSecret[:], nil }) if err != nil { diff --git a/pkg/config/dynamic_config_manager.go b/pkg/config/dynamic_config_manager.go index cd792e2ebd..f04d643cc9 100644 --- a/pkg/config/dynamic_config_manager.go +++ b/pkg/config/dynamic_config_manager.go @@ -87,7 +87,7 @@ func (m *DynamicConfigManager) Start(ctx context.Context) error { return nil } -func (m *DynamicConfigManager) Stop(ctx context.Context) error { +func (m *DynamicConfigManager) Stop(_ context.Context) error { m.mu.Lock() defer m.mu.Unlock() for _, ch := range m.pushChannels { diff --git a/pkg/keyvisual/decorator/decorator.go b/pkg/keyvisual/decorator/decorator.go index 3551531660..af552fa775 100644 --- a/pkg/keyvisual/decorator/decorator.go +++ b/pkg/keyvisual/decorator/decorator.go @@ -39,14 +39,14 @@ type naiveLabelStrategy struct{} type naiveLabeler struct{} -func (s naiveLabelStrategy) ReloadConfig(cfg *config.KeyVisualConfig) {} +func (s naiveLabelStrategy) ReloadConfig(_ *config.KeyVisualConfig) {} func (s naiveLabelStrategy) NewLabeler() Labeler { return naiveLabeler{} } // CrossBorder always returns false. So naiveLabelStrategy believes that there are no cross-border situations. -func (e naiveLabeler) CrossBorder(startKey, endKey string) bool { +func (e naiveLabeler) CrossBorder(_, _ string) bool { return false } diff --git a/pkg/keyvisual/decorator/decorator_test.go b/pkg/keyvisual/decorator/decorator_test.go index f879faf726..8596d6d52d 100644 --- a/pkg/keyvisual/decorator/decorator_test.go +++ b/pkg/keyvisual/decorator/decorator_test.go @@ -5,9 +5,9 @@ package decorator import ( "testing" - . "github.com/pingcap/check" + "github.com/pingcap/check" ) func TestDecorator(t *testing.T) { - TestingT(t) + check.TestingT(t) } diff --git a/pkg/keyvisual/decorator/separator.go b/pkg/keyvisual/decorator/separator.go index 31763918cd..876a890b6d 100644 --- a/pkg/keyvisual/decorator/separator.go +++ b/pkg/keyvisual/decorator/separator.go @@ -40,7 +40,7 @@ func (s *separatorLabelStrategy) NewLabeler() Labeler { } // CrossBorder is temporarily not considering cross-border logic. -func (e *separatorLabeler) CrossBorder(startKey, endKey string) bool { +func (e *separatorLabeler) CrossBorder(_, _ string) bool { return false } diff --git a/pkg/keyvisual/decorator/tidb.go b/pkg/keyvisual/decorator/tidb.go index 1cea2b5184..27320c22d1 100644 --- a/pkg/keyvisual/decorator/tidb.go +++ b/pkg/keyvisual/decorator/tidb.go @@ -62,7 +62,7 @@ type tidbLabeler struct { Buffer model.KeyInfoBuffer } -func (s *tidbLabelStrategy) ReloadConfig(cfg *config.KeyVisualConfig) {} +func (s *tidbLabelStrategy) ReloadConfig(_ *config.KeyVisualConfig) {} func (s *tidbLabelStrategy) Background(ctx context.Context) { ticker := time.NewTicker(time.Minute) diff --git a/pkg/keyvisual/decorator/tidb_test.go b/pkg/keyvisual/decorator/tidb_test.go index 51b7d27b50..3e3990a643 100644 --- a/pkg/keyvisual/decorator/tidb_test.go +++ b/pkg/keyvisual/decorator/tidb_test.go @@ -3,9 +3,9 @@ package decorator import ( - . "github.com/pingcap/check" + "github.com/pingcap/check" ) -var _ = Suite(&testTiDBSuite{}) +var _ = check.Suite(&testTiDBSuite{}) type testTiDBSuite struct{} diff --git a/pkg/keyvisual/input/file.go b/pkg/keyvisual/input/file.go index 6f1416abe5..0c58393365 100644 --- a/pkg/keyvisual/input/file.go +++ b/pkg/keyvisual/input/file.go @@ -35,7 +35,7 @@ func (input *fileInput) GetStartTime() time.Time { return input.Now.Add(input.StartTime.Sub(input.EndTime)) } -func (input *fileInput) Background(ctx context.Context, stat *storage.Stat) { +func (input *fileInput) Background(_ context.Context, stat *storage.Stat) { log.Info("keyvisual load files from", zap.Time("start-time", input.StartTime)) fileTime := input.StartTime for !fileTime.After(input.EndTime) { diff --git a/pkg/keyvisual/matrix/average.go b/pkg/keyvisual/matrix/average.go index d6748f6613..7f452b4580 100644 --- a/pkg/keyvisual/matrix/average.go +++ b/pkg/keyvisual/matrix/average.go @@ -11,11 +11,11 @@ type averageSplitStrategy struct{} type averageSplitter struct{} -func (averageSplitStrategy) NewSplitter(chunks []chunk, compactKeys []string) Splitter { +func (averageSplitStrategy) NewSplitter(_ []chunk, _ []string) Splitter { return averageSplitter{} } -func (averageSplitter) Split(dst, src chunk, tag splitTag, axesIndex int) { +func (averageSplitter) Split(dst, src chunk, tag splitTag, _ int) { CheckPartOf(dst.Keys, src.Keys) if len(dst.Keys) == len(src.Keys) { diff --git a/pkg/keyvisual/matrix/average_test.go b/pkg/keyvisual/matrix/average_test.go index 3d5168c900..60f212cf6e 100644 --- a/pkg/keyvisual/matrix/average_test.go +++ b/pkg/keyvisual/matrix/average_test.go @@ -3,9 +3,9 @@ package matrix import ( - . "github.com/pingcap/check" + "github.com/pingcap/check" ) -var _ = Suite(&testAverageSuite{}) +var _ = check.Suite(&testAverageSuite{}) type testAverageSuite struct{} diff --git a/pkg/keyvisual/matrix/axis_test.go b/pkg/keyvisual/matrix/axis_test.go index 1630b99041..9d41e5b0a6 100644 --- a/pkg/keyvisual/matrix/axis_test.go +++ b/pkg/keyvisual/matrix/axis_test.go @@ -3,14 +3,14 @@ package matrix import ( - . "github.com/pingcap/check" + "github.com/pingcap/check" ) -var _ = Suite(&testAxisSuite{}) +var _ = check.Suite(&testAxisSuite{}) type testAxisSuite struct{} -func (s *testAxisSuite) TestChunkReduce(c *C) { +func (s *testAxisSuite) TestChunkReduce(c *check.C) { testcases := []struct { keys []string values []uint64 @@ -34,6 +34,6 @@ func (s *testAxisSuite) TestChunkReduce(c *C) { for _, testcase := range testcases { originChunk := createChunk(testcase.keys, testcase.values) reduceChunk := originChunk.Reduce(testcase.newKeys) - c.Assert(reduceChunk.Values, DeepEquals, testcase.newValues) + c.Assert(reduceChunk.Values, check.DeepEquals, testcase.newValues) } } diff --git a/pkg/keyvisual/matrix/distance_test.go b/pkg/keyvisual/matrix/distance_test.go index 128c4ff813..414f945059 100644 --- a/pkg/keyvisual/matrix/distance_test.go +++ b/pkg/keyvisual/matrix/distance_test.go @@ -12,11 +12,11 @@ import ( "sync" "testing" - . "github.com/pingcap/check" + "github.com/pingcap/check" "go.uber.org/fx" ) -var _ = Suite(&testDistanceSuite{}) +var _ = check.Suite(&testDistanceSuite{}) type testDistanceSuite struct{} diff --git a/pkg/keyvisual/matrix/key.go b/pkg/keyvisual/matrix/key.go index 8e946b5c12..af54222d11 100644 --- a/pkg/keyvisual/matrix/key.go +++ b/pkg/keyvisual/matrix/key.go @@ -3,9 +3,7 @@ package matrix import ( - "reflect" "sync" - "unsafe" ) // KeyMap is used for string intern. @@ -29,7 +27,5 @@ func (km *KeyMap) SaveKeys(keys []string) { } func equal(keyA, keyB string) bool { - pA := (*reflect.StringHeader)(unsafe.Pointer(&keyA)) // #nosec - pB := (*reflect.StringHeader)(unsafe.Pointer(&keyB)) // #nosec - return pA.Data == pB.Data && pA.Len == pB.Len + return keyA == keyB } diff --git a/pkg/keyvisual/matrix/key_test.go b/pkg/keyvisual/matrix/key_test.go index d2eb7898d2..e85ea221ec 100644 --- a/pkg/keyvisual/matrix/key_test.go +++ b/pkg/keyvisual/matrix/key_test.go @@ -3,9 +3,9 @@ package matrix import ( - . "github.com/pingcap/check" + "github.com/pingcap/check" ) -var _ = Suite(&testKeySuite{}) +var _ = check.Suite(&testKeySuite{}) type testKeySuite struct{} diff --git a/pkg/keyvisual/matrix/matrix_test.go b/pkg/keyvisual/matrix/matrix_test.go index 6252249591..c01c93a188 100644 --- a/pkg/keyvisual/matrix/matrix_test.go +++ b/pkg/keyvisual/matrix/matrix_test.go @@ -5,13 +5,13 @@ package matrix import ( "testing" - . "github.com/pingcap/check" + "github.com/pingcap/check" ) func TestMatrix(t *testing.T) { - TestingT(t) + check.TestingT(t) } -var _ = Suite(&testMatrixSuite{}) +var _ = check.Suite(&testMatrixSuite{}) type testMatrixSuite struct{} diff --git a/pkg/keyvisual/matrix/plane_test.go b/pkg/keyvisual/matrix/plane_test.go index 73724149c4..3219453ec7 100644 --- a/pkg/keyvisual/matrix/plane_test.go +++ b/pkg/keyvisual/matrix/plane_test.go @@ -3,9 +3,9 @@ package matrix import ( - . "github.com/pingcap/check" + "github.com/pingcap/check" ) -var _ = Suite(&testPlaneSuite{}) +var _ = check.Suite(&testPlaneSuite{}) type testPlaneSuite struct{} diff --git a/pkg/keyvisual/matrix/util_test.go b/pkg/keyvisual/matrix/util_test.go index 649b162aa9..ce1518e2c9 100644 --- a/pkg/keyvisual/matrix/util_test.go +++ b/pkg/keyvisual/matrix/util_test.go @@ -3,14 +3,14 @@ package matrix import ( - . "github.com/pingcap/check" + "github.com/pingcap/check" ) -var _ = Suite(&testUtilSuite{}) +var _ = check.Suite(&testUtilSuite{}) type testUtilSuite struct{} -func (s *testUtilSuite) TestMemset(c *C) { +func (s *testUtilSuite) TestMemset(c *check.C) { s1 := []uint64{3, 3, 3, 3, 3} s2 := []uint64{0, 0, 0, 0, 0} s3 := []int{6, 6, 6, 6} @@ -19,6 +19,6 @@ func (s *testUtilSuite) TestMemset(c *C) { MemsetUint64(s1, 0) MemsetInt(s3, 9) - c.Assert(s1, DeepEquals, s2) - c.Assert(s3, DeepEquals, s4) + c.Assert(s1, check.DeepEquals, s2) + c.Assert(s3, check.DeepEquals, s4) } diff --git a/pkg/keyvisual/region/utils.go b/pkg/keyvisual/region/utils.go index 860911f8e2..ce16d4189b 100644 --- a/pkg/keyvisual/region/utils.go +++ b/pkg/keyvisual/region/utils.go @@ -3,31 +3,21 @@ package region import ( - "reflect" "unsafe" ) // String converts slice of bytes to string without copy. -func String(b []byte) (s string) { +func String(b []byte) string { if len(b) == 0 { return "" } - pbytes := (*reflect.SliceHeader)(unsafe.Pointer(&b)) // #nosec - pstring := (*reflect.StringHeader)(unsafe.Pointer(&s)) // #nosec - pstring.Data = pbytes.Data - pstring.Len = pbytes.Len - return + return unsafe.String(&b[0], len(b)) // #nosec } // Bytes converts a string into a byte slice. Need to make sure that the byte slice is not modified. -func Bytes(s string) (b []byte) { +func Bytes(s string) []byte { if len(s) == 0 { - return + return nil } - pbytes := (*reflect.SliceHeader)(unsafe.Pointer(&b)) // #nosec - pstring := (*reflect.StringHeader)(unsafe.Pointer(&s)) // #nosec - pbytes.Data = pstring.Data - pbytes.Len = pstring.Len - pbytes.Cap = pstring.Len - return + return unsafe.Slice(unsafe.StringData(s), len(s)) // #nosec } diff --git a/pkg/keyvisual/service.go b/pkg/keyvisual/service.go index 59ce82d6f0..4da0ae5a08 100644 --- a/pkg/keyvisual/service.go +++ b/pkg/keyvisual/service.go @@ -298,7 +298,7 @@ func (s *Service) provideLocals() (*config.Config, *clientv3.Client, *pd.Client, func newWaitGroup(lc fx.Lifecycle) *sync.WaitGroup { wg := &sync.WaitGroup{} lc.Append(fx.Hook{ - OnStop: func(ctx context.Context) error { + OnStop: func(_ context.Context) error { wg.Wait() return nil }, @@ -321,7 +321,7 @@ func newStrategy(lc fx.Lifecycle, wg *sync.WaitGroup, labelStrategy decorator.La func newStat( lc fx.Lifecycle, wg *sync.WaitGroup, - etcdClient *clientv3.Client, + _ *clientv3.Client, db *dbstore.DB, in input.StatInput, strategy *matrix.Strategy, diff --git a/pkg/keyvisual/storage/model_test.go b/pkg/keyvisual/storage/model_test.go index 13c5f67f44..e0899f7537 100644 --- a/pkg/keyvisual/storage/model_test.go +++ b/pkg/keyvisual/storage/model_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - . "github.com/pingcap/check" + "github.com/pingcap/check" "gorm.io/driver/sqlite" "gorm.io/gorm" @@ -16,17 +16,17 @@ import ( ) func TestDbstore(t *testing.T) { - TestingT(t) + check.TestingT(t) } -var _ = Suite(&testDbstoreSuite{}) +var _ = check.Suite(&testDbstoreSuite{}) type testDbstoreSuite struct { dir string db *dbstore.DB } -func (t *testDbstoreSuite) SetUpTest(c *C) { +func (t *testDbstoreSuite) SetUpTest(c *check.C) { t.dir = c.MkDir() gormDB, err := gorm.Open(sqlite.Open(path.Join(t.dir, "test.sqlite.db"))) if err != nil { @@ -35,16 +35,16 @@ func (t *testDbstoreSuite) SetUpTest(c *C) { t.db = &dbstore.DB{DB: gormDB} } -func (t *testDbstoreSuite) TestCreateTableAxisModelIfNotExists(c *C) { +func (t *testDbstoreSuite) TestCreateTableAxisModelIfNotExists(c *check.C) { isExist, err := CreateTableAxisModelIfNotExists(t.db) - c.Assert(isExist, Equals, false) - c.Assert(err, IsNil) + c.Assert(isExist, check.Equals, false) + c.Assert(err, check.IsNil) isExist, err = CreateTableAxisModelIfNotExists(t.db) - c.Assert(isExist, Equals, true) - c.Assert(err, IsNil) + c.Assert(isExist, check.Equals, true) + c.Assert(err, check.IsNil) } -func (t *testDbstoreSuite) TestClearTableAxisModel(c *C) { +func (t *testDbstoreSuite) TestClearTableAxisModel(c *check.C) { _, err := CreateTableAxisModelIfNotExists(t.db) if err != nil { c.Fatalf("Create table AxisModel error: %v", err) @@ -63,19 +63,19 @@ func (t *testDbstoreSuite) TestClearTableAxisModel(c *C) { if err != nil { c.Fatalf("Count table AxisModel error: %v", err) } - c.Assert(count, Equals, int64(1)) + c.Assert(count, check.Equals, int64(1)) err = ClearTableAxisModel(t.db) - c.Assert(err, IsNil) + c.Assert(err, check.IsNil) err = t.db.Table(tableAxisModelName).Count(&count).Error if err != nil { c.Fatalf("Count table AxisModel error: %v", err) } - c.Assert(count, Equals, int64(0)) + c.Assert(count, check.Equals, int64(0)) } -func (t *testDbstoreSuite) TestAxisModelFunc(c *C) { +func (t *testDbstoreSuite) TestAxisModelFunc(c *check.C) { _, err := CreateTableAxisModelIfNotExists(t.db) if err != nil { c.Fatalf("Create table AxisModel error: %v", err) @@ -91,34 +91,34 @@ func (t *testDbstoreSuite) TestAxisModelFunc(c *C) { c.Fatalf("NewAxisModel error: %v", err) } err = axisModel.Insert(t.db) - c.Assert(err, IsNil) + c.Assert(err, check.IsNil) axisModels, err := FindAxisModelsOrderByTime(t.db, layerNum) if err != nil { c.Fatalf("FindAxisModelOrderByTime error: %v", err) } - c.Assert(len(axisModels), Equals, 1) + c.Assert(len(axisModels), check.Equals, 1) axisModelDeepEqual(axisModels[0], axisModel, c) obtainedAxis, err := axisModels[0].UnmarshalAxis() if err != nil { c.Fatalf("UnmarshalAxis error: %v", err) } - c.Assert(obtainedAxis, DeepEquals, axis) + c.Assert(obtainedAxis, check.DeepEquals, axis) err = axisModel.Delete(t.db) - c.Assert(err, IsNil) + c.Assert(err, check.IsNil) var count int64 err = t.db.Table(tableAxisModelName).Count(&count).Error if err != nil { c.Fatalf("Count table AxisModel error: %v", err) } - c.Assert(count, Equals, int64(0)) + c.Assert(count, check.Equals, int64(0)) err = axisModel.Delete(t.db) - c.Assert(err, IsNil) + c.Assert(err, check.IsNil) } -func (t *testDbstoreSuite) TestAxisModelsFindAndDelete(c *C) { +func (t *testDbstoreSuite) TestAxisModelsFindAndDelete(c *check.C) { _, err := CreateTableAxisModelIfNotExists(t.db) if err != nil { c.Fatalf("Create table AxisModel error: %v", err) @@ -146,36 +146,36 @@ func (t *testDbstoreSuite) TestAxisModelsFindAndDelete(c *C) { if err != nil { c.Fatalf("Count table AxisModel error: %v", err) } - c.Assert(count, Equals, int64(int(maxLayerNum)*axisModelNumEachLayer)) + c.Assert(count, check.Equals, int64(int(maxLayerNum)*axisModelNumEachLayer)) findLayerNum := maxLayerNum - 1 axisModels, err := FindAxisModelsOrderByTime(t.db, findLayerNum) - c.Assert(err, IsNil) + c.Assert(err, check.IsNil) axisModelsDeepEqual(axisModels, axisModelList[findLayerNum], c) err = DeleteAxisModelsByLayerNum(t.db, findLayerNum) - c.Assert(err, IsNil) + c.Assert(err, check.IsNil) axisModels, err = FindAxisModelsOrderByTime(t.db, findLayerNum) - c.Assert(err, IsNil) - c.Assert(axisModels, HasLen, 0) + c.Assert(err, check.IsNil) + c.Assert(axisModels, check.HasLen, 0) err = t.db.Table(tableAxisModelName).Count(&count).Error if err != nil { c.Fatalf("Count table AxisModel error: %v", err) } - c.Assert(count, Equals, int64(int(maxLayerNum-1)*axisModelNumEachLayer)) + c.Assert(count, check.Equals, int64(int(maxLayerNum-1)*axisModelNumEachLayer)) } -func axisModelsDeepEqual(obtainedAxisModels []*AxisModel, expectedAxisModels []*AxisModel, c *C) { - c.Assert(len(obtainedAxisModels), Equals, len(expectedAxisModels)) +func axisModelsDeepEqual(obtainedAxisModels []*AxisModel, expectedAxisModels []*AxisModel, c *check.C) { + c.Assert(len(obtainedAxisModels), check.Equals, len(expectedAxisModels)) for i := range obtainedAxisModels { axisModelDeepEqual(obtainedAxisModels[i], expectedAxisModels[i], c) } } -func axisModelDeepEqual(obtainedAxisModel *AxisModel, expectedAxisModel *AxisModel, c *C) { - c.Assert(obtainedAxisModel.Time.Unix(), Equals, expectedAxisModel.Time.Unix()) +func axisModelDeepEqual(obtainedAxisModel *AxisModel, expectedAxisModel *AxisModel, c *check.C) { + c.Assert(obtainedAxisModel.Time.Unix(), check.Equals, expectedAxisModel.Time.Unix()) obtainedAxisModel.Time = expectedAxisModel.Time - c.Assert(obtainedAxisModel, DeepEquals, expectedAxisModel) + c.Assert(obtainedAxisModel, check.DeepEquals, expectedAxisModel) } diff --git a/pkg/keyvisual/storage/region_test.go b/pkg/keyvisual/storage/region_test.go index 96402804dd..e9c5fce646 100644 --- a/pkg/keyvisual/storage/region_test.go +++ b/pkg/keyvisual/storage/region_test.go @@ -5,13 +5,13 @@ package storage import ( "testing" - . "github.com/pingcap/check" + "github.com/pingcap/check" ) func TestRegion(t *testing.T) { - TestingT(t) + check.TestingT(t) } -var _ = Suite(&testRegionSuite{}) +var _ = check.Suite(&testRegionSuite{}) type testRegionSuite struct{} diff --git a/pkg/keyvisual/storage/stat_test.go b/pkg/keyvisual/storage/stat_test.go index c1cc5be464..8548fbda97 100644 --- a/pkg/keyvisual/storage/stat_test.go +++ b/pkg/keyvisual/storage/stat_test.go @@ -5,13 +5,13 @@ package storage import ( "testing" - . "github.com/pingcap/check" + "github.com/pingcap/check" ) func TestStat(t *testing.T) { - TestingT(t) + check.TestingT(t) } -var _ = Suite(&testStatSuite{}) +var _ = check.Suite(&testStatSuite{}) type testStatSuite struct{} diff --git a/pkg/tidb/model/codec_test.go b/pkg/tidb/model/codec_test.go index 69bd5bdd89..1022496e19 100644 --- a/pkg/tidb/model/codec_test.go +++ b/pkg/tidb/model/codec_test.go @@ -5,32 +5,32 @@ package model import ( "testing" - . "github.com/pingcap/check" + "github.com/pingcap/check" ) func TestTable(t *testing.T) { - TestingT(t) + check.TestingT(t) } -var _ = Suite(&testCodecSuite{}) +var _ = check.Suite(&testCodecSuite{}) type testCodecSuite struct{} -func (s *testCodecSuite) TestDecodeBytes(c *C) { +func (s *testCodecSuite) TestDecodeBytes(c *check.C) { key := "abcdefghijklmnopqrstuvwxyz" for i := 0; i < len(key); i++ { _, k, err := decodeBytes(encodeBytes([]byte(key[:i])), nil) - c.Assert(err, IsNil) - c.Assert(string(k), Equals, key[:i]) + c.Assert(err, check.IsNil) + c.Assert(string(k), check.Equals, key[:i]) } } -func (s *testCodecSuite) TestTiDBInfo(c *C) { +func (s *testCodecSuite) TestTiDBInfo(c *check.C) { buf := new(KeyInfoBuffer) // no encode _, err := buf.DecodeKey([]byte("t\x80\x00\x00\x00\x00\x00\x00\xff")) - c.Assert(err, NotNil) + c.Assert(err, check.NotNil) testcases := []struct { Key string @@ -101,14 +101,14 @@ func (s *testCodecSuite) TestTiDBInfo(c *C) { for _, t := range testcases { key := encodeBytes([]byte(t.Key)) _, err := buf.DecodeKey(key) - c.Assert(err, IsNil) + c.Assert(err, check.IsNil) isMeta, tableID := buf.MetaOrTable() - c.Assert(isMeta, Equals, t.IsMeta) - c.Assert(tableID, Equals, t.TableID) + c.Assert(isMeta, check.Equals, t.IsMeta) + c.Assert(tableID, check.Equals, t.TableID) isCommonHandle, rowID := buf.RowInfo() - c.Assert(isCommonHandle, Equals, t.IsCommonHandle) - c.Assert(rowID, Equals, t.RowID) + c.Assert(isCommonHandle, check.Equals, t.IsCommonHandle) + c.Assert(rowID, check.Equals, t.RowID) indexID := buf.IndexInfo() - c.Assert(indexID, Equals, t.IndexID) + c.Assert(indexID, check.Equals, t.IndexID) } } diff --git a/pkg/tidb/proxy.go b/pkg/tidb/proxy.go index 3a2effa7b3..e1b2d2ea4a 100644 --- a/pkg/tidb/proxy.go +++ b/pkg/tidb/proxy.go @@ -75,7 +75,7 @@ func (p *proxy) port() int { func (p *proxy) updateRemotes(remotes map[string]struct{}) { if len(remotes) == 0 { - p.remotes.Range(func(key, value interface{}) bool { + p.remotes.Range(func(key, _ interface{}) bool { p.remotes.Delete(key) return true }) @@ -93,7 +93,7 @@ func (p *proxy) updateRemotes(remotes map[string]struct{}) { } } // remove old remote - p.remotes.Range(func(key, value interface{}) bool { + p.remotes.Range(func(key, _ interface{}) bool { addr := key.(string) if _, ok := remotes[addr]; !ok { log.Debug("proxy discards remote", zap.String("remote", addr)) @@ -182,7 +182,7 @@ func (p *proxy) doCheck(ctx context.Context) { case <-ctx.Done(): return case <-time.After(p.checkInterval): - p.remotes.Range(func(key, value interface{}) bool { + p.remotes.Range(func(_, value interface{}) bool { rmt := value.(*remote) if rmt.isActive() { return true @@ -203,7 +203,7 @@ func (p *proxy) doCheck(ctx context.Context) { func (p *proxy) run(ctx context.Context) { endpoints := make([]string, 0) - p.remotes.Range(func(key, value interface{}) bool { + p.remotes.Range(func(_, value interface{}) bool { r := value.(*remote) endpoints = append(endpoints, r.addr) return true diff --git a/pkg/tidb/proxy_test.go b/pkg/tidb/proxy_test.go index e360624f4c..72ac7af785 100644 --- a/pkg/tidb/proxy_test.go +++ b/pkg/tidb/proxy_test.go @@ -24,7 +24,7 @@ func TestProxy(t *testing.T) { } defer l.Close() want := "hello proxy" - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, err := w.Write([]byte(want)) if err != nil { t.Fatal(err) @@ -66,7 +66,7 @@ func TestProxyPick(t *testing.T) { var currentPicked int for i := 0; i < n; i++ { idx := i - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { picked[idx] = true currentPicked = idx _, err := w.Write([]byte(responseData)) diff --git a/pkg/uiserver/uiserver.go b/pkg/uiserver/uiserver.go index 0538f1cd75..28e6b9fba4 100644 --- a/pkg/uiserver/uiserver.go +++ b/pkg/uiserver/uiserver.go @@ -137,7 +137,7 @@ func Handler(root http.FileSystem) http.Handler { return httpgzip.FileServer(root, httpgzip.FileServerOptions{IndexHTML: true}) } - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + return http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = io.WriteString(w, "Dashboard UI is not built. Use `UI=1 make`.\n") }) } diff --git a/pkg/utils/sys_schema.go b/pkg/utils/sys_schema.go index 442a51cd08..2d2501daf5 100644 --- a/pkg/utils/sys_schema.go +++ b/pkg/utils/sys_schema.go @@ -24,7 +24,7 @@ func ProvideSysSchema(lc fx.Lifecycle) *SysSchema { s := NewSysSchema() lc.Append(fx.Hook{ - OnStop: func(ctx context.Context) error { + OnStop: func(_ context.Context) error { return s.Close() }, }) diff --git a/pkg/utils/topology/scheduling.go b/pkg/utils/topology/scheduling.go index 76cd786b43..db3c940f6b 100644 --- a/pkg/utils/topology/scheduling.go +++ b/pkg/utils/topology/scheduling.go @@ -12,7 +12,7 @@ import ( "github.com/pingcap/tidb-dashboard/util/netutil" ) -func FetchSchedulingTopology(ctx context.Context, pdClient *pd.Client) ([]SchedulingInfo, error) { +func FetchSchedulingTopology(_ context.Context, pdClient *pd.Client) ([]SchedulingInfo, error) { nodes := make([]SchedulingInfo, 0) data, err := pdClient.WithoutPrefix().SendGetRequest("/pd/api/v2/ms/members/scheduling") if err != nil { diff --git a/pkg/utils/topology/tiproxy.go b/pkg/utils/topology/tiproxy.go index 029b8c708d..8e6438a7a5 100644 --- a/pkg/utils/topology/tiproxy.go +++ b/pkg/utils/topology/tiproxy.go @@ -95,7 +95,7 @@ func FetchTiProxyTopology(ctx context.Context, etcdClient *clientv3.Client) ([]T return nodes, nil } -func parseTiProxyInfo(address string, value []byte) (*TiProxyInfo, error) { +func parseTiProxyInfo(_ string, value []byte) (*TiProxyInfo, error) { ds := struct { GitHash string `json:"git_hash"` Version string `json:"version"` diff --git a/pkg/utils/topology/tso.go b/pkg/utils/topology/tso.go index f5bafb7560..35d79c5a85 100644 --- a/pkg/utils/topology/tso.go +++ b/pkg/utils/topology/tso.go @@ -12,7 +12,7 @@ import ( "github.com/pingcap/tidb-dashboard/util/netutil" ) -func FetchTSOTopology(ctx context.Context, pdClient *pd.Client) ([]TSOInfo, error) { +func FetchTSOTopology(_ context.Context, pdClient *pd.Client) ([]TSOInfo, error) { nodes := make([]TSOInfo, 0) data, err := pdClient.WithoutPrefix().SendGetRequest("/pd/api/v2/ms/members/tso") if err != nil { diff --git a/scripts/go.mod b/scripts/go.mod index 34d0a57d7f..b856b0b992 100644 --- a/scripts/go.mod +++ b/scripts/go.mod @@ -1,6 +1,6 @@ module scripts -go 1.18 +go 1.21 require ( github.com/codeskyblue/go-sh v0.0.0-20200712050446-30169cf553fe @@ -9,15 +9,17 @@ require ( github.com/pingcap/tidb-dashboard v0.0.0-00010101000000-000000000000 github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546 github.com/swaggo/swag v1.7.9 - github.com/vektra/mockery/v2 v2.14.1 - go.uber.org/zap v1.19.0 - golang.org/x/mod v0.8.0 + github.com/vektra/mockery/v2 v2.40.3 + go.uber.org/zap v1.21.0 + golang.org/x/mod v0.14.0 ) require ( github.com/KyleBanks/depth v1.2.1 // indirect github.com/PuerkitoBio/purell v1.1.1 // indirect github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect + github.com/benbjohnson/clock v1.1.0 // indirect + github.com/chigopher/pathlib v0.19.1 // indirect github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect @@ -27,37 +29,37 @@ require ( github.com/go-openapi/spec v0.20.4 // indirect github.com/go-openapi/swag v0.19.15 // indirect github.com/hashicorp/hcl v1.0.0 // indirect - github.com/inconshreveable/mousetrap v1.0.1 // indirect + github.com/huandu/xstrings v1.4.0 // indirect + github.com/iancoleman/strcase v0.2.0 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/jinzhu/copier v0.3.5 // indirect github.com/josharian/intern v1.0.0 // indirect - github.com/magiconair/properties v1.8.6 // indirect + github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.6 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/rs/zerolog v1.28.0 // indirect + github.com/rs/zerolog v1.29.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect - github.com/spf13/afero v1.9.2 // indirect + github.com/spf13/afero v1.9.3 // indirect github.com/spf13/cast v1.5.0 // indirect github.com/spf13/cobra v1.6.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/spf13/viper v1.13.0 // indirect - github.com/subosito/gotenv v1.4.1 // indirect + github.com/spf13/viper v1.15.0 // indirect + github.com/subosito/gotenv v1.4.2 // indirect github.com/urfave/cli/v2 v2.3.0 // indirect go.uber.org/atomic v1.9.0 // indirect - go.uber.org/multierr v1.7.0 // indirect - golang.org/x/crypto v0.9.0 // indirect - golang.org/x/net v0.10.0 // indirect - golang.org/x/sys v0.8.0 // indirect - golang.org/x/term v0.8.0 // indirect - golang.org/x/text v0.9.0 // indirect - golang.org/x/tools v0.6.0 // indirect + go.uber.org/multierr v1.8.0 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/sys v0.16.0 // indirect + golang.org/x/term v0.16.0 // indirect + golang.org/x/text v0.14.0 // indirect + golang.org/x/tools v0.17.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/scripts/go.sum b/scripts/go.sum index f0b999bb6b..69b74a142a 100644 --- a/scripts/go.sum +++ b/scripts/go.sum @@ -46,11 +46,16 @@ github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbt github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/agiledragon/gomonkey/v2 v2.3.1 h1:k+UnUY0EMNYUFUAQVETGY9uUTxjMdnUkP0ARyJS1zzs= +github.com/agiledragon/gomonkey/v2 v2.3.1/go.mod h1:ap1AmDzcVOAz1YpeJ3TCzIgstoaWLA6jbbgxfB4w2iY= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= +github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= +github.com/chigopher/pathlib v0.19.1 h1:RoLlUJc0CqBGwq239cilyhxPNLXTK+HXoASGyGznx5A= +github.com/chigopher/pathlib v0.19.1/go.mod h1:tzC1dZLW8o33UQpWkNkhvPwL5n4yyFRFm/jL1YGWFvY= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -76,14 +81,18 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= +github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= +github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= +github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= +github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -98,9 +107,13 @@ github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= +github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -138,7 +151,8 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -161,27 +175,38 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU= +github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0= +github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg= +github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= +github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= -github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= -github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= +github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA= @@ -200,18 +225,20 @@ github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE= -github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= -github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= +github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U= github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/pingcap/errors v0.11.0/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pingcap/errors v0.11.5-0.20200917111840-a15ef68f753d h1:TH18wFO5Nq/zUQuWu9ms2urgZnLP69XJYiI2JZAkUGc= +github.com/pingcap/errors v0.11.5-0.20200917111840-a15ef68f753d/go.mod h1:g4vx//d6VakjJ0mk7iLBlKA8LFavV/sAVINT/1PFxeQ= github.com/pingcap/log v0.0.0-20210906054005-afc726e70354 h1:SvWCbCPh1YeHd9yQLksvJYAgft6wLTY1aNG81tpyscQ= github.com/pingcap/log v0.0.0-20210906054005-afc726e70354/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -223,9 +250,10 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY= -github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= +github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w= +github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -234,8 +262,8 @@ github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749/go.mod h1:ZY1cvUeJ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546 h1:pXY9qYc/MP5zdvqWEUH6SjNiu7VhSjuVFTFiTcphaLU= github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= -github.com/spf13/afero v1.9.2 h1:j49Hj62F0n+DaZ1dDCvhABaPNSGNkt32oRFxI33IEMw= -github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= +github.com/spf13/afero v1.9.3 h1:41FoI0fD7OR7mGcKE/aOiLkGreyf8ifIOQmJANWogMk= +github.com/spf13/afero v1.9.3/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= @@ -244,8 +272,8 @@ github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmq github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.13.0 h1:BWSJ/M+f+3nmdz9bxB+bWX28kkALN2ok11D0rSo8EJU= -github.com/spf13/viper v1.13.0/go.mod h1:Icm2xNL3/8uyh/wFuB1jI7TiTNKp8632Nwegu+zgdYw= +github.com/spf13/viper v1.15.0 h1:js3yy885G8xwJa6iOISGFwd+qlUo5AvyXb7CiihdtiU= +github.com/spf13/viper v1.15.0/go.mod h1:fFcTBJxvhhzSJiZy8n+PeW6t8l+KeT/uTARa0jHOQLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= @@ -260,20 +288,23 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= -github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= +github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= +github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/swaggo/swag v1.7.9 h1:6vCG5mm43ebDzGlZPMGYrYI4zKFfOr5kicQX8qjeDwc= github.com/swaggo/swag v1.7.9/go.mod h1:gZ+TJ2w/Ve1RwQsA2IRoSOTidHz6DX+PIG8GWvbnoLU= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= +github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= -github.com/vektra/mockery/v2 v2.14.1 h1:Xamr4zUkFBDGdZhJ6iCiJ1AwkGRmUgZd8zkwjRXt+TU= -github.com/vektra/mockery/v2 v2.14.1/go.mod h1:bnD1T8tExSgPD1ripLkDbr60JA9VtQeu12P3wgLZd7M= +github.com/vektra/mockery/v2 v2.40.3 h1:IZ2lydSDFsY0khnEsbSu13VLcqSsa6UYSS/8F+uOJmo= +github.com/vektra/mockery/v2 v2.40.3/go.mod h1:KYBZF/7sqOa86BaOZPYsoCZWEWLS90a5oBLg2pVudxY= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -283,14 +314,18 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec= go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= -go.uber.org/zap v1.19.0 h1:mZQZefskPPCMIBCSEH0v2/iUqqLrYtaeqwD6FUGUnFE= +go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= +go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= +go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= +go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= +golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -298,8 +333,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= -golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= +golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -322,7 +357,6 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 h1:2M3HP5CCK1Si9FQhwnzYhXdG6DXeebvUHFpre8QvbyI= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= @@ -334,8 +368,9 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -367,9 +402,10 @@ golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -389,7 +425,9 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -422,19 +460,21 @@ golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= +golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -443,8 +483,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -496,8 +536,9 @@ golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= +golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -591,6 +632,7 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= diff --git a/scripts/lint.sh b/scripts/lint.sh index fc8bcd2ca9..a0200299f6 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -10,7 +10,7 @@ PROJECT_DIR="$(dirname "$DIR")" cd $PROJECT_DIR LINT_BIN=./bin/golangci-lint -REQUIRED_VERSION=1.51.1 +REQUIRED_VERSION=1.59.1 NEED_DOWNLOAD=true echo "+ Check golangci-lint binary" diff --git a/tests/integration/diagnose_report_test.go b/tests/integration/diagnose_report_test.go index 3243644519..e5669ff23f 100644 --- a/tests/integration/diagnose_report_test.go +++ b/tests/integration/diagnose_report_test.go @@ -5,15 +5,15 @@ package integration import ( "testing" - . "github.com/pingcap/check" + "github.com/pingcap/check" ) func TestT(t *testing.T) { - CustomVerboseFlag = true - TestingT(t) + check.CustomVerboseFlag = true + check.TestingT(t) } -var _ = Suite(&testReportSuite{}) +var _ = check.Suite(&testReportSuite{}) type testReportSuite struct{} diff --git a/util/client/httpclient/response.go b/util/client/httpclient/response.go index 993f0e7f3b..f7733a2bb7 100644 --- a/util/client/httpclient/response.go +++ b/util/client/httpclient/response.go @@ -72,7 +72,7 @@ func (lResp *LazyResponse) doExecutionOnce() { client.SetRedirectPolicy(resty.FlexibleRedirectPolicy(10)) client.SetTimeout(defaultTimeout) if lResp.requestSnapshot.debugTag != "" { - client.SetPreRequestHook(func(rc *resty.Client, rr *http.Request) error { + client.SetPreRequestHook(func(_ *resty.Client, rr *http.Request) error { log.Info("Send request", zap.String("kindTag", lResp.requestSnapshot.kindTag), zap.String("debugTag", lResp.requestSnapshot.debugTag), diff --git a/util/client/httpclient/response_test.go b/util/client/httpclient/response_test.go index 2426a831ec..9b736d37b5 100644 --- a/util/client/httpclient/response_test.go +++ b/util/client/httpclient/response_test.go @@ -26,7 +26,7 @@ func TestReadBodyAsString(t *testing.T) { requestTimes := atomic.Int32{} responseStatus := atomic.Int32{} - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { requestTimes.Inc() w.WriteHeader(int(responseStatus.Load())) _, _ = fmt.Fprintf(w, "Basically OK, Req #%d", requestTimes.Load()) @@ -106,7 +106,7 @@ func TestFinish(t *testing.T) { requestTimes := atomic.Int32{} responseStatus := atomic.Int32{} - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { requestTimes.Inc() w.WriteHeader(int(responseStatus.Load())) _, _ = fmt.Fprintf(w, "Basically OK, Req #%d", requestTimes.Load()) @@ -161,7 +161,7 @@ func TestFinish(t *testing.T) { } func TestReadBodyAsJSON(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprintln(w, `{"foo":"bar"}`) })) defer ts.Close() @@ -191,7 +191,7 @@ func TestReadBodyAsJSON(t *testing.T) { func TestReadBodyAsJSON_UnmarshalFailure(t *testing.T) { requestTimes := atomic.Int32{} - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { requestTimes.Inc() _, _ = fmt.Fprintln(w, `bad_json`) })) @@ -241,7 +241,7 @@ func (w *myWriter) Write(p []byte) (int, error) { func TestPipeBody(t *testing.T) { requestTimes := atomic.Int32{} - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { requestTimes.Inc() _, _ = fmt.Fprintln(w, "Hello world") })) @@ -273,7 +273,7 @@ func TestPipeBody(t *testing.T) { // Now the server write data chunk by chunk... ctx, cancel := context.WithCancel(context.Background()) - ts = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { requestTimes.Inc() _, _ = w.Write([]byte("Partial...")) w.(http.Flusher).Flush() @@ -324,7 +324,7 @@ func TestPipeBody(t *testing.T) { } func TestResponseHeader(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.Header().Add("foo", "bar") w.WriteHeader(http.StatusAlreadyReported) _, _ = fmt.Fprintln(w, "Fine!") @@ -340,12 +340,12 @@ func TestResponseHeader(t *testing.T) { } func TestSetURL(t *testing.T) { - ts1 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts1 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprintln(w, "Result from server 1") })) defer ts1.Close() - ts2 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts2 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprintln(w, "Result from server 2") })) defer ts2.Close() @@ -397,12 +397,12 @@ func TestLR(t *testing.T) { } func TestGet(t *testing.T) { - ts1 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts1 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprintln(w, "Result from server 1") })) defer ts1.Close() - ts2 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts2 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprintln(w, "Result from server 2") })) defer ts2.Close() @@ -564,7 +564,7 @@ func TestFailureStatusCode(t *testing.T) { requestTimes := atomic.Int32{} responseStatus := atomic.Int32{} - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { requestTimes.Inc() w.WriteHeader(int(responseStatus.Load())) _, _ = fmt.Fprintf(w, "Fail from req #%d", requestTimes.Load()) @@ -750,11 +750,11 @@ func TestConnectionReuse(t *testing.T) { closedConn := atomic.Int32{} requestTimes := atomic.Int32{} - ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { requestTimes.Inc() _, _ = fmt.Fprintf(w, "Req #%d", requestTimes.Load()) })) - ts.Config.ConnState = func(c net.Conn, cs http.ConnState) { + ts.Config.ConnState = func(_ net.Conn, cs http.ConnState) { switch cs { case http.StateNew: newConn.Inc() @@ -840,7 +840,7 @@ func TestClone(t *testing.T) { func TestTimeoutHeader(t *testing.T) { requestTimes := atomic.Int32{} ctx, cancel := context.WithCancel(context.Background()) - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { requestTimes.Inc() select { case <-ctx.Done(): @@ -903,7 +903,7 @@ func TestTimeoutHeader(t *testing.T) { func TestTimeoutBody(t *testing.T) { requestTimes := atomic.Int32{} ctx, cancel := context.WithCancel(context.Background()) - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { requestTimes.Inc() _, _ = w.Write([]byte("Partial...")) w.(http.Flusher).Flush() diff --git a/util/gormutil/virtualview/schema.go b/util/gormutil/virtualview/schema.go index aa1076aba4..ac06c80137 100644 --- a/util/gormutil/virtualview/schema.go +++ b/util/gormutil/virtualview/schema.go @@ -69,7 +69,7 @@ type identVisitor struct { idents []string } -func (v *identVisitor) Enter(node *ast.Node) {} +func (v *identVisitor) Enter(_ *ast.Node) {} func (v *identVisitor) Exit(node *ast.Node) { if n, ok := (*node).(*ast.IdentifierNode); ok { v.idents = append(v.idents, n.Value) diff --git a/util/proxy/proxy.go b/util/proxy/proxy.go index 697069e254..df529f4b8c 100644 --- a/util/proxy/proxy.go +++ b/util/proxy/proxy.go @@ -95,7 +95,7 @@ func (p *Proxy) SetUpstreams(addresses []string) { if len(addresses) == 0 { log.Debug("All endpoints are removed from the upstream list", zap.String("kindTag", p.config.KindTag)) - p.upstreams.Range(func(key, value interface{}) bool { + p.upstreams.Range(func(key, _ interface{}) bool { p.upstreams.Delete(key) return true }) @@ -119,7 +119,7 @@ func (p *Proxy) SetUpstreams(addresses []string) { for _, addr := range addresses { addrSet[addr] = struct{}{} } - p.upstreams.Range(func(key, value interface{}) bool { + p.upstreams.Range(func(key, _ interface{}) bool { addr := key.(string) if _, ok := addrSet[addr]; !ok { log.Debug("An endpoint is removed from the upstream list", @@ -207,7 +207,7 @@ func (p *Proxy) pickOneLastActiveUpstream() *upstream { } var picked *upstream - p.upstreams.Range(func(key, value interface{}) bool { + p.upstreams.Range(func(_, value interface{}) bool { r := value.(*upstream) if r.IsActive() { picked = r @@ -222,7 +222,7 @@ func (p *Proxy) pickOneLastActiveUpstream() *upstream { func (p *Proxy) probeActiveUpstreams() { activeUpstreams := 0 - p.upstreams.Range(func(key, value interface{}) bool { + p.upstreams.Range(func(_, value interface{}) bool { r := value.(*upstream) if r.IsActive() { activeUpstreams++ diff --git a/util/proxy/proxy_test.go b/util/proxy/proxy_test.go index ff0fa36d59..8181524328 100644 --- a/util/proxy/proxy_test.go +++ b/util/proxy/proxy_test.go @@ -284,7 +284,7 @@ func TestBrokenServer(t *testing.T) { require.NoError(t, err) defer p.Close() - server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprintln(w, "foo") })) defer server.Close() diff --git a/util/rest/error_test.go b/util/rest/error_test.go index 2df61be866..0d0e7e41f1 100644 --- a/util/rest/error_test.go +++ b/util/rest/error_test.go @@ -151,7 +151,7 @@ func (suite *ErrorHandlerFnTestSuite) TestWithRecoveryMiddleware() { engine := gin.New() engine.Use(gin.Recovery()) engine.Use(ErrorHandlerFn()) - engine.GET("/test", func(c *gin.Context) { + engine.GET("/test", func(_ *gin.Context) { panic("some panic") }) diff --git a/util/rest/fileswap/server.go b/util/rest/fileswap/server.go index 7808ca6445..1f4995b2ab 100644 --- a/util/rest/fileswap/server.go +++ b/util/rest/fileswap/server.go @@ -69,7 +69,7 @@ func (s *Handler) parseClaimsFromToken(tokenString string) (*downloadTokenClaims token, err := jwt.ParseWithClaims( tokenString, &downloadTokenClaims{}, - func(token *jwt.Token) (interface{}, error) { + func(_ *jwt.Token) (interface{}, error) { return s.secret, nil }) if token != nil { diff --git a/util/testutil/http_server.go b/util/testutil/http_server.go index dfa1845c17..0842ad8495 100644 --- a/util/testutil/http_server.go +++ b/util/testutil/http_server.go @@ -16,7 +16,7 @@ func GetHTTPServerHost(server *httptest.Server) string { } func NewHTTPServer(response string) *httptest.Server { - return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = fmt.Fprintln(w, response) })) } @@ -28,7 +28,7 @@ func NewHTTPServerAtHost(response string, host string) *httptest.Server { } server := &httptest.Server{ Listener: l, - Config: &http.Server{Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // nolint:gosec + Config: &http.Server{Handler: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { // nolint:gosec _, _ = fmt.Fprintln(w, response) })}, } @@ -49,7 +49,7 @@ func NewMultiServer(n int, responsePattern string) *MultiServerHelper { for i := 0; i < n; i++ { func(i int) { - s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { resp := fmt.Sprintf(responsePattern, i) lastActiveID.Store(int32(i)) lastResponse.Store(resp) diff --git a/util/topo/mock_TopologyProvider.go b/util/topo/mock_TopologyProvider.go index d66c45e255..0646d73a71 100644 --- a/util/topo/mock_TopologyProvider.go +++ b/util/topo/mock_TopologyProvider.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.14.1. DO NOT EDIT. +// Code generated by mockery v2.40.3. DO NOT EDIT. package topo @@ -17,7 +17,15 @@ type MockTopologyProvider struct { func (_m *MockTopologyProvider) GetAlertManager(ctx context.Context) (*AlertManagerInfo, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for GetAlertManager") + } + var r0 *AlertManagerInfo + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (*AlertManagerInfo, error)); ok { + return rf(ctx) + } if rf, ok := ret.Get(0).(func(context.Context) *AlertManagerInfo); ok { r0 = rf(ctx) } else { @@ -26,7 +34,6 @@ func (_m *MockTopologyProvider) GetAlertManager(ctx context.Context) (*AlertMana } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context) error); ok { r1 = rf(ctx) } else { @@ -40,7 +47,15 @@ func (_m *MockTopologyProvider) GetAlertManager(ctx context.Context) (*AlertMana func (_m *MockTopologyProvider) GetGrafana(ctx context.Context) (*GrafanaInfo, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for GetGrafana") + } + var r0 *GrafanaInfo + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (*GrafanaInfo, error)); ok { + return rf(ctx) + } if rf, ok := ret.Get(0).(func(context.Context) *GrafanaInfo); ok { r0 = rf(ctx) } else { @@ -49,7 +64,6 @@ func (_m *MockTopologyProvider) GetGrafana(ctx context.Context) (*GrafanaInfo, e } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context) error); ok { r1 = rf(ctx) } else { @@ -63,7 +77,15 @@ func (_m *MockTopologyProvider) GetGrafana(ctx context.Context) (*GrafanaInfo, e func (_m *MockTopologyProvider) GetPD(ctx context.Context) ([]PDInfo, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for GetPD") + } + var r0 []PDInfo + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]PDInfo, error)); ok { + return rf(ctx) + } if rf, ok := ret.Get(0).(func(context.Context) []PDInfo); ok { r0 = rf(ctx) } else { @@ -72,7 +94,6 @@ func (_m *MockTopologyProvider) GetPD(ctx context.Context) ([]PDInfo, error) { } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context) error); ok { r1 = rf(ctx) } else { @@ -86,7 +107,15 @@ func (_m *MockTopologyProvider) GetPD(ctx context.Context) ([]PDInfo, error) { func (_m *MockTopologyProvider) GetPrometheus(ctx context.Context) (*PrometheusInfo, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for GetPrometheus") + } + var r0 *PrometheusInfo + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (*PrometheusInfo, error)); ok { + return rf(ctx) + } if rf, ok := ret.Get(0).(func(context.Context) *PrometheusInfo); ok { r0 = rf(ctx) } else { @@ -95,7 +124,6 @@ func (_m *MockTopologyProvider) GetPrometheus(ctx context.Context) (*PrometheusI } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context) error); ok { r1 = rf(ctx) } else { @@ -109,7 +137,15 @@ func (_m *MockTopologyProvider) GetPrometheus(ctx context.Context) (*PrometheusI func (_m *MockTopologyProvider) GetTiDB(ctx context.Context) ([]TiDBInfo, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for GetTiDB") + } + var r0 []TiDBInfo + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]TiDBInfo, error)); ok { + return rf(ctx) + } if rf, ok := ret.Get(0).(func(context.Context) []TiDBInfo); ok { r0 = rf(ctx) } else { @@ -118,7 +154,6 @@ func (_m *MockTopologyProvider) GetTiDB(ctx context.Context) ([]TiDBInfo, error) } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context) error); ok { r1 = rf(ctx) } else { @@ -132,7 +167,15 @@ func (_m *MockTopologyProvider) GetTiDB(ctx context.Context) ([]TiDBInfo, error) func (_m *MockTopologyProvider) GetTiFlash(ctx context.Context) ([]TiFlashStoreInfo, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for GetTiFlash") + } + var r0 []TiFlashStoreInfo + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]TiFlashStoreInfo, error)); ok { + return rf(ctx) + } if rf, ok := ret.Get(0).(func(context.Context) []TiFlashStoreInfo); ok { r0 = rf(ctx) } else { @@ -141,7 +184,6 @@ func (_m *MockTopologyProvider) GetTiFlash(ctx context.Context) ([]TiFlashStoreI } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context) error); ok { r1 = rf(ctx) } else { @@ -155,7 +197,15 @@ func (_m *MockTopologyProvider) GetTiFlash(ctx context.Context) ([]TiFlashStoreI func (_m *MockTopologyProvider) GetTiKV(ctx context.Context) ([]TiKVStoreInfo, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for GetTiKV") + } + var r0 []TiKVStoreInfo + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]TiKVStoreInfo, error)); ok { + return rf(ctx) + } if rf, ok := ret.Get(0).(func(context.Context) []TiKVStoreInfo); ok { r0 = rf(ctx) } else { @@ -164,7 +214,6 @@ func (_m *MockTopologyProvider) GetTiKV(ctx context.Context) ([]TiKVStoreInfo, e } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context) error); ok { r1 = rf(ctx) } else { @@ -174,13 +223,12 @@ func (_m *MockTopologyProvider) GetTiKV(ctx context.Context) ([]TiKVStoreInfo, e return r0, r1 } -type mockConstructorTestingTNewMockTopologyProvider interface { +// NewMockTopologyProvider creates a new instance of MockTopologyProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockTopologyProvider(t interface { mock.TestingT Cleanup(func()) -} - -// NewMockTopologyProvider creates a new instance of MockTopologyProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewMockTopologyProvider(t mockConstructorTestingTNewMockTopologyProvider) *MockTopologyProvider { +}) *MockTopologyProvider { mock := &MockTopologyProvider{} mock.Mock.Test(t) From c4d04335ed5f9fb8f0ec7bc79cdfc04547654058 Mon Sep 17 00:00:00 2001 From: baurine <2008.hbl@gmail.com> Date: Fri, 23 Aug 2024 14:59:55 +0800 Subject: [PATCH 2/2] test --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eb5083bb30..60149b6b11 100644 --- a/README.md +++ b/README.md @@ -88,4 +88,4 @@ Copyright 2020 PingCAP, Inc. [pd]: https://github.com/pingcap/pd [asktug.com]: https://asktug.com/ - \ No newline at end of file +