From 6782f1f7219ee48a763edb9e48be58e6241b2ab5 Mon Sep 17 00:00:00 2001 From: rogerogers Date: Wed, 28 Feb 2024 16:56:59 +0800 Subject: [PATCH 1/2] style: lint fix Signed-off-by: rogerogers --- .github/workflows/pr-check.yml | 6 +----- book-shop/app/item/main.go | 1 - open-payment-platform/pkg/auth/auth.go | 4 ++-- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index bdcc3040..88618eae 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -33,15 +33,11 @@ jobs: strategy: matrix: ${{ fromJson(needs.resolve-modules.outputs.matrix) }} steps: - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: 1.21 - uses: actions/checkout@v3 - name: Lint uses: golangci/golangci-lint-action@v3 with: version: latest working-directory: ${{ matrix.workdir }} - args: --timeout 30m -E gofumpt + args: --timeout 30m -E gofumpt --go 1.21 skip-pkg-cache: true diff --git a/book-shop/app/item/main.go b/book-shop/app/item/main.go index 452df044..b10d707e 100644 --- a/book-shop/app/item/main.go +++ b/book-shop/app/item/main.go @@ -49,7 +49,6 @@ func main() { ) err = svr.Run() - if err != nil { log.Println(err.Error()) } diff --git a/open-payment-platform/pkg/auth/auth.go b/open-payment-platform/pkg/auth/auth.go index 90392f3f..dadbc6a6 100644 --- a/open-payment-platform/pkg/auth/auth.go +++ b/open-payment-platform/pkg/auth/auth.go @@ -16,9 +16,9 @@ package auth import ( + "crypto/rand" "encoding/hex" "errors" - "math/rand" ) type SignType string @@ -54,6 +54,6 @@ func (a *authSM3) Verify(sign string, data map[string]interface{}) bool { func (a *authSM3) Sign(data map[string]interface{}) string { result := make([]byte, 10) - rand.Read(result) + rand.Read(result) //nolint:errcheck return hex.EncodeToString(result) } From 551ea1f4a018e01f3cea27368d502cce04fa9be1 Mon Sep 17 00:00:00 2001 From: rogerogers Date: Wed, 28 Feb 2024 17:05:25 +0800 Subject: [PATCH 2/2] style: lint fix Signed-off-by: rogerogers --- gomall/app/cart/biz/service/add_item.go | 1 - gomall/app/frontend/biz/service/register.go | 1 - gomall/app/frontend/infra/mtl/metric.go | 1 - gomall/app/payment/biz/service/charge.go | 1 - gomall/app/product/biz/model/product.go | 1 - 5 files changed, 5 deletions(-) diff --git a/gomall/app/cart/biz/service/add_item.go b/gomall/app/cart/biz/service/add_item.go index a00fbeac..64195b91 100644 --- a/gomall/app/cart/biz/service/add_item.go +++ b/gomall/app/cart/biz/service/add_item.go @@ -50,7 +50,6 @@ func (s *AddItemService) Run(req *cart.AddItemReq) (resp *cart.AddItemResp, err ProductId: req.Item.ProductId, Qty: uint32(req.Item.Quantity), }) - if err != nil { return nil, kerrors.NewBizStatusError(50000, err.Error()) } diff --git a/gomall/app/frontend/biz/service/register.go b/gomall/app/frontend/biz/service/register.go index 17c088ed..f37b71a1 100644 --- a/gomall/app/frontend/biz/service/register.go +++ b/gomall/app/frontend/biz/service/register.go @@ -47,7 +47,6 @@ func (h *RegisterService) Run(req *auth.RegisterReq) (resp *common.Empty, err er session := sessions.Default(h.RequestContext) session.Set("user_id", res.UserId) err = session.Save() - if err != nil { return nil, err } diff --git a/gomall/app/frontend/infra/mtl/metric.go b/gomall/app/frontend/infra/mtl/metric.go index 57769285..f9618f87 100644 --- a/gomall/app/frontend/infra/mtl/metric.go +++ b/gomall/app/frontend/infra/mtl/metric.go @@ -53,7 +53,6 @@ func initMetric() route.CtxCallback { } registryInfo := ®istry.Info{Addr: ip, ServiceName: "prometheus", Weight: 1} err = r.Register(registryInfo) - if err != nil { hlog.Error(err) } diff --git a/gomall/app/payment/biz/service/charge.go b/gomall/app/payment/biz/service/charge.go index 9bd86785..55249ce5 100644 --- a/gomall/app/payment/biz/service/charge.go +++ b/gomall/app/payment/biz/service/charge.go @@ -44,7 +44,6 @@ func (s *ChargeService) Run(req *payment.ChargeReq) (resp *payment.ChargeResp, e } err = card.Validate(true) - if err != nil { return nil, kerrors.NewBizStatusError(400, err.Error()) } diff --git a/gomall/app/product/biz/model/product.go b/gomall/app/product/biz/model/product.go index c1a23362..f8d1c352 100644 --- a/gomall/app/product/biz/model/product.go +++ b/gomall/app/product/biz/model/product.go @@ -76,7 +76,6 @@ func (c CachedProductQuery) GetById(productId int) (product Product, err error) } return nil }() - if err != nil { product, err = c.productQuery.GetById(productId) if err != nil {