From 5efc7ebdfcc3f90f7952b46836ffeeaff95d3f1f Mon Sep 17 00:00:00 2001 From: rogerogers Date: Thu, 4 Jan 2024 13:38:06 +0800 Subject: [PATCH] style(product): fix product lint Signed-off-by: rogerogers --- gomall/app/product/biz/dal/mysql/init.go | 2 +- gomall/app/product/biz/dal/redis/init.go | 2 +- gomall/app/product/biz/service/get_product_test.go | 1 - gomall/app/product/biz/service/list_products_test.go | 1 - gomall/app/product/biz/service/search_products_test.go | 4 ++-- gomall/app/product/conf/conf.go | 3 +-- gomall/app/product/handler.go | 1 + gomall/app/product/infra/mtl/log.go | 2 +- gomall/app/product/infra/mtl/metric.go | 4 ++-- gomall/app/product/infra/mtl/tracing.go | 3 ++- gomall/app/product/rpc/product/product_default.go | 1 + 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gomall/app/product/biz/dal/mysql/init.go b/gomall/app/product/biz/dal/mysql/init.go index a5e50b9b..3ffc0131 100644 --- a/gomall/app/product/biz/dal/mysql/init.go +++ b/gomall/app/product/biz/dal/mysql/init.go @@ -44,7 +44,7 @@ func Init() { } if os.Getenv("GO_ENV") != "online" { needDemoData := !DB.Migrator().HasTable(&model.Product{}) - DB.AutoMigrate( + DB.AutoMigrate( //nolint:errcheck &model.Product{}, &model.Category{}, ) diff --git a/gomall/app/product/biz/dal/redis/init.go b/gomall/app/product/biz/dal/redis/init.go index 3d259650..6e818c70 100644 --- a/gomall/app/product/biz/dal/redis/init.go +++ b/gomall/app/product/biz/dal/redis/init.go @@ -44,5 +44,5 @@ func Init() { if err := mtl.Registry.Register(redisprometheus.NewCollector("default", "product", RedisClient)); err != nil { klog.Error("redis metric collect error ", err) } - redisotel.InstrumentTracing(RedisClient) + redisotel.InstrumentTracing(RedisClient) //nolint:errcheck } diff --git a/gomall/app/product/biz/service/get_product_test.go b/gomall/app/product/biz/service/get_product_test.go index 1288a463..ecaa2070 100644 --- a/gomall/app/product/biz/service/get_product_test.go +++ b/gomall/app/product/biz/service/get_product_test.go @@ -35,5 +35,4 @@ func TestGetProduct_Run(t *testing.T) { t.Errorf("unexpected nil response") } // todo: edit your unit test - } diff --git a/gomall/app/product/biz/service/list_products_test.go b/gomall/app/product/biz/service/list_products_test.go index 892d579d..ebc10d6f 100644 --- a/gomall/app/product/biz/service/list_products_test.go +++ b/gomall/app/product/biz/service/list_products_test.go @@ -35,5 +35,4 @@ func TestListProducts_Run(t *testing.T) { t.Errorf("unexpected nil response") } // todo: edit your unit test - } diff --git a/gomall/app/product/biz/service/search_products_test.go b/gomall/app/product/biz/service/search_products_test.go index 52e35169..b3ed91a6 100644 --- a/gomall/app/product/biz/service/search_products_test.go +++ b/gomall/app/product/biz/service/search_products_test.go @@ -16,8 +16,9 @@ package service import ( "context" - product "github.com/cloudwego/biz-demo/gomall/app/product/kitex_gen/product" "testing" + + product "github.com/cloudwego/biz-demo/gomall/app/product/kitex_gen/product" ) func TestSearchProducts_Run(t *testing.T) { @@ -34,5 +35,4 @@ func TestSearchProducts_Run(t *testing.T) { t.Errorf("unexpected nil response") } // todo: edit your unit test - } diff --git a/gomall/app/product/conf/conf.go b/gomall/app/product/conf/conf.go index 1252f03a..8b5593a2 100644 --- a/gomall/app/product/conf/conf.go +++ b/gomall/app/product/conf/conf.go @@ -71,8 +71,7 @@ type Registry struct { Password string `yaml:"password"` } -type ConfigServer struct { -} +type ConfigServer struct{} // GetConf gets configuration instance func GetConf() *Config { diff --git a/gomall/app/product/handler.go b/gomall/app/product/handler.go index fcb7dab0..fc122b27 100644 --- a/gomall/app/product/handler.go +++ b/gomall/app/product/handler.go @@ -16,6 +16,7 @@ package main import ( "context" + "github.com/cloudwego/biz-demo/gomall/app/product/biz/service" product "github.com/cloudwego/biz-demo/gomall/app/product/kitex_gen/product" ) diff --git a/gomall/app/product/infra/mtl/log.go b/gomall/app/product/infra/mtl/log.go index 116347d0..489f3711 100644 --- a/gomall/app/product/infra/mtl/log.go +++ b/gomall/app/product/infra/mtl/log.go @@ -39,7 +39,7 @@ func initLog() { FlushInterval: time.Minute, } server.RegisterShutdownHook(func() { - output.Sync() + output.Sync() //nolint:errcheck }) } log := kitexzap.NewLogger(opts...) diff --git a/gomall/app/product/infra/mtl/metric.go b/gomall/app/product/infra/mtl/metric.go index 4dfa2730..d949432b 100644 --- a/gomall/app/product/infra/mtl/metric.go +++ b/gomall/app/product/infra/mtl/metric.go @@ -54,7 +54,7 @@ func initMetric() { err = r.Register(registryInfo) server.RegisterShutdownHook(func() { - r.Deregister(registryInfo) + r.Deregister(registryInfo) //nolint:errcheck }) if err != nil { @@ -62,5 +62,5 @@ func initMetric() { } 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 } diff --git a/gomall/app/product/infra/mtl/tracing.go b/gomall/app/product/infra/mtl/tracing.go index 2ba94c62..88032420 100644 --- a/gomall/app/product/infra/mtl/tracing.go +++ b/gomall/app/product/infra/mtl/tracing.go @@ -16,6 +16,7 @@ package mtl import ( "context" + "github.com/cloudwego/kitex/server" "github.com/cloudwego/biz-demo/gomall/app/product/conf" @@ -31,7 +32,7 @@ var TracerProvider *tracesdk.TracerProvider func initTracing() { exporter, err := otlptracegrpc.New(context.Background()) server.RegisterShutdownHook(func() { - exporter.Shutdown(context.Background()) + exporter.Shutdown(context.Background()) //nolint:errcheck }) if err != nil { panic(err) diff --git a/gomall/app/product/rpc/product/product_default.go b/gomall/app/product/rpc/product/product_default.go index e7b5bab7..0c4d00d7 100644 --- a/gomall/app/product/rpc/product/product_default.go +++ b/gomall/app/product/rpc/product/product_default.go @@ -16,6 +16,7 @@ package product import ( "context" + product "github.com/cloudwego/biz-demo/gomall/app/product/kitex_gen/product" "github.com/cloudwego/kitex/client/callopt" "github.com/cloudwego/kitex/pkg/klog"