Skip to content

Commit

Permalink
style(payment): fix payment lint
Browse files Browse the repository at this point in the history
Signed-off-by: rogerogers <[email protected]>
  • Loading branch information
rogerogers committed Jan 4, 2024
1 parent a22e050 commit d3478ee
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion gomall/app/payment/biz/dal/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ import (
)

func Init() {
//redis.Init()
// redis.Init()
mysql.Init()
}
2 changes: 1 addition & 1 deletion gomall/app/payment/biz/dal/mysql/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func Init() {
panic(err)
}
if os.Getenv("GO_ENV") != "online" {
DB.AutoMigrate(
DB.AutoMigrate( //nolint:errcheck
&model.PaymentLog{},
)
}
Expand Down
4 changes: 1 addition & 3 deletions gomall/app/payment/biz/dal/redis/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import (
"github.com/redis/go-redis/v9"
)

var (
RedisClient *redis.Client
)
var RedisClient *redis.Client

func Init() {
RedisClient = redis.NewClient(&redis.Options{
Expand Down
3 changes: 2 additions & 1 deletion gomall/app/payment/biz/model/payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ package model

import (
"context"
"gorm.io/gorm"
"time"

"gorm.io/gorm"
)

type PaymentLog struct {
Expand Down
3 changes: 3 additions & 0 deletions gomall/app/payment/biz/service/charge.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ func (s *ChargeService) Run(req *payment.ChargeRequest) (resp *payment.ChargeRes
}

translationId, err := uuid.NewRandom()
if err != nil {
return nil, err
}
err = model.CreatePaymentLog(mysql.DB, s.ctx, &model.PaymentLog{
UserId: req.UserId,
OrderId: req.OrderId,
Expand Down
4 changes: 2 additions & 2 deletions gomall/app/payment/biz/service/charge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ package service

import (
"context"
payment "github.com/cloudwego/biz-demo/gomall/app/payment/kitex_gen/payment"
"testing"

payment "github.com/cloudwego/biz-demo/gomall/app/payment/kitex_gen/payment"
)

func TestCharge_Run(t *testing.T) {
Expand All @@ -34,5 +35,4 @@ func TestCharge_Run(t *testing.T) {
t.Errorf("unexpected nil response")
}
// todo: edit your unit test

}
3 changes: 1 addition & 2 deletions gomall/app/payment/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package conf

import (
"io/ioutil"
"os"
"path/filepath"
"sync"
Expand Down Expand Up @@ -79,7 +78,7 @@ func GetConf() *Config {
func initConf() {
prefix := "conf"
confFileRelPath := filepath.Join(prefix, filepath.Join(GetEnv(), "conf.yaml"))
content, err := ioutil.ReadFile(confFileRelPath)
content, err := os.ReadFile(confFileRelPath)
if err != nil {
panic(err)
}
Expand Down
1 change: 1 addition & 0 deletions gomall/app/payment/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package main

import (
"context"

"github.com/cloudwego/biz-demo/gomall/app/payment/biz/service"
payment "github.com/cloudwego/biz-demo/gomall/app/payment/kitex_gen/payment"
)
Expand Down
2 changes: 1 addition & 1 deletion gomall/app/payment/infra/mtl/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func initLog() {
FlushInterval: time.Minute,
}
server.RegisterShutdownHook(func() {
output.Sync()
output.Sync() //nolint:errcheck
})
}
log := kitexzap.NewLogger(opts...)
Expand Down
4 changes: 2 additions & 2 deletions gomall/app/payment/infra/mtl/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ func initMetric() {
_ = r.Register(registryInfo)

server.RegisterShutdownHook(func() {
r.Deregister(registryInfo)
r.Deregister(registryInfo) //nolint:errcheck
})

http.Handle("/metrics", promhttp.HandlerFor(Registry, promhttp.HandlerOpts{}))
go http.ListenAndServe(conf.GetConf().Kitex.MetricsPort, nil)
go http.ListenAndServe(conf.GetConf().Kitex.MetricsPort, nil) //nolint:errcheck
}
3 changes: 2 additions & 1 deletion gomall/app/payment/infra/mtl/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package mtl

import (
"context"

"github.com/cloudwego/kitex/server"

"github.com/cloudwego/biz-demo/gomall/app/payment/conf"
Expand All @@ -34,7 +35,7 @@ func initTracing() {
panic(err)
}
server.RegisterShutdownHook(func() {
exporter.Shutdown(context.Background())
exporter.Shutdown(context.Background()) //nolint:errcheck
})
processor := tracesdk.NewBatchSpanProcessor(exporter)
res, err := resource.New(context.Background(), resource.WithAttributes(semconv.ServiceNameKey.String(conf.GetConf().Kitex.Service)))
Expand Down
1 change: 1 addition & 0 deletions gomall/app/payment/rpc/payment/payment_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package payment

import (
"context"

payment "github.com/cloudwego/biz-demo/gomall/app/payment/kitex_gen/payment"

"github.com/cloudwego/biz-demo/gomall/app/payment/kitex_gen/payment/paymentservice"
Expand Down
1 change: 1 addition & 0 deletions gomall/app/payment/rpc/payment/payment_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package payment

import (
"context"

payment "github.com/cloudwego/biz-demo/gomall/app/payment/kitex_gen/payment"
"github.com/cloudwego/kitex/client/callopt"
"github.com/cloudwego/kitex/pkg/klog"
Expand Down

0 comments on commit d3478ee

Please sign in to comment.