Skip to content

Commit 9dffe46

Browse files
committed
run golangci-lint
1 parent fbe1426 commit 9dffe46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+186
-257
lines changed

config/config.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ type ViperConfOptions struct{}
2323
type Option func(c *viperConf)
2424

2525
func NewViperConfig(options ...Option) Config {
26-
2726
viperConf := &viperConf{}
2827

2928
for _, option := range options {
@@ -104,7 +103,7 @@ func (vc *viperConf) GetTime(key string) time.Time { return vc.Viper.GetTime(key
104103

105104
func (vc *viperConf) GetDuration(key string) time.Duration { return vc.Viper.GetDuration(key) }
106105

107-
//func GetIntSlice(key string) []int { return config.GetIntSlice(key) }
106+
// func GetIntSlice(key string) []int { return config.GetIntSlice(key) }
108107

109108
func (vc *viperConf) GetStringSlice(key string) []string { return vc.Viper.GetStringSlice(key) }
110109

config/mem_config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (mc *MemConfig) GetDuration(key string) time.Duration {
6969
return cast.ToDuration(mc.Get(key))
7070
}
7171

72-
//func (mc *MemConfig) GetIntSlice(key string) []int { return viper.GetIntSlice(key) }
72+
// func (mc *MemConfig) GetIntSlice(key string) []int { return viper.GetIntSlice(key) }
7373

7474
func (mc *MemConfig) GetStringSlice(key string) []string {
7575
return cast.ToStringSlice(mc.Get(key))
@@ -87,7 +87,7 @@ func (mc *MemConfig) GetStringMapStringSlice(key string) map[string][]string {
8787
return cast.ToStringMapStringSlice(mc.Get(key))
8888
}
8989

90-
//TODO 还没实现
90+
// TODO 还没实现
9191
func (mc *MemConfig) GetSizeInBytes(key string) uint {
9292
return 0
9393
}

config/mem_config_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ func TestGetString(t *testing.T) {
2828
}
2929

3030
func TestGetBool(t *testing.T) {
31-
3231
memConfig := NewMemConfig()
3332

3433
memConfig.Set("test", true)
@@ -40,7 +39,6 @@ func TestGetBool(t *testing.T) {
4039
}
4140

4241
func TestGetInt(t *testing.T) {
43-
4442
memConfig := NewMemConfig()
4543

4644
memConfig.Set("test", 100)
@@ -85,7 +83,6 @@ func TestGetUint(t *testing.T) {
8583
}
8684

8785
func TestGetUint32(t *testing.T) {
88-
8986
memConfig := NewMemConfig()
9087

9188
memConfig.Set("test", 100)
@@ -97,7 +94,6 @@ func TestGetUint32(t *testing.T) {
9794
}
9895

9996
func TestGetUint64(t *testing.T) {
100-
10197
memConfig := NewMemConfig()
10298

10399
memConfig.Set("test", 100)
@@ -120,7 +116,6 @@ func TestGetFloat64(t *testing.T) {
120116
}
121117

122118
func TestGetTime(t *testing.T) {
123-
124119
memConfig := NewMemConfig()
125120

126121
now := time.Now()
@@ -133,7 +128,6 @@ func TestGetTime(t *testing.T) {
133128
}
134129

135130
func TestGetDuration(t *testing.T) {
136-
137131
memConfig := NewMemConfig()
138132
memConfig.Set("test", time.Duration(100))
139133

@@ -144,7 +138,6 @@ func TestGetDuration(t *testing.T) {
144138
}
145139

146140
func TestGetStringSlice(t *testing.T) {
147-
148141
memConfig := NewMemConfig()
149142
memConfig.Set("test", []string{"config", "test"})
150143

@@ -155,7 +148,6 @@ func TestGetStringSlice(t *testing.T) {
155148
}
156149

157150
func TestGetStringMap(t *testing.T) {
158-
159151
memConfig := NewMemConfig()
160152
memConfig.Set("test", map[string]interface{}{"config": 1000})
161153

@@ -187,7 +179,6 @@ func TestGetStringMapString(t *testing.T) {
187179
if str != "test" {
188180
t.Errorf("结果错误,应该是 test, 实际 %s", str)
189181
}
190-
191182
}
192183

193184
func TestGetStringMapStringSlice(t *testing.T) {

config/null_config.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import (
77
"github.com/spf13/viper"
88
)
99

10-
type NullConfig struct {
11-
}
10+
type NullConfig struct {}
1211

1312
func NewNullConfig() *NullConfig {
1413
return &NullConfig{}
@@ -62,7 +61,7 @@ func (nc *NullConfig) GetDuration(key string) time.Duration {
6261
return cast.ToDuration(0)
6362
}
6463

65-
//func (nc *NullConfig) GetIntSlice(key string) []int { return viper.GetIntSlice(key) }
64+
// func (nc *NullConfig) GetIntSlice(key string) []int { return viper.GetIntSlice(key) }
6665

6766
func (nc *NullConfig) GetStringSlice(key string) []string {
6867
return []string{}
@@ -80,7 +79,7 @@ func (nc *NullConfig) GetStringMapStringSlice(key string) map[string][]string {
8079
return map[string][]string{}
8180
}
8281

83-
//TODO 还没实现
82+
// TODO 还没实现
8483
func (nc *NullConfig) GetSizeInBytes(key string) uint {
8584
return 0
8685
}

container/esim.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
var esimOnce sync.Once
1515
var onceEsim *Esim
1616

17-
const DEFAULT_APPNAME = "esim"
18-
const DEFAULT_PROMETHEUS_HTTP_ADDR = "9002"
17+
const DefaultAppname = "esim"
18+
const DefaultPrometheusHTTPArrd = "9002"
1919

2020
//esim init start
2121
type Esim struct {
@@ -28,6 +28,7 @@ type Esim struct {
2828
Tracer opentracing.Tracer
2929
}
3030

31+
//nolint:varcheck,unused,deadcode
3132
var esimSet = wire.NewSet(
3233
wire.Struct(new(Esim), "*"),
3334
provideConf,
@@ -52,7 +53,7 @@ var prometheusFunc = func(conf config.Config, logger log.Logger) *prometheus.Pro
5253
if conf.GetString("prometheus_http_addr") != "" {
5354
httpAddr = conf.GetString("prometheus_http_addr")
5455
} else {
55-
httpAddr = DEFAULT_PROMETHEUS_HTTP_ADDR
56+
httpAddr = DefaultPrometheusHTTPArrd
5657
}
5758
return prometheus.NewPrometheus(httpAddr, logger)
5859
}
@@ -85,7 +86,7 @@ var tracerFunc = func(conf config.Config, logger log.Logger) opentracing.Tracer
8586
if conf.GetString("appname") != "" {
8687
appname = conf.GetString("appname")
8788
} else {
88-
appname = DEFAULT_APPNAME
89+
appname = DefaultAppname
8990
}
9091
return eot.NewTracer(appname, logger)
9192
}

container/esim_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package container
2+
3+
import (
4+
"testing"
5+
"github.com/stretchr/testify/assert"
6+
)
7+
8+
9+
func TestNewEsim(t *testing.T) {
10+
esim := NewEsim()
11+
12+
assert.NotNil(t, esim.Logger)
13+
assert.NotNil(t, esim.Conf)
14+
assert.NotNil(t, esim.Tracer)
15+
assert.NotNil(t, esim.prometheus)
16+
}

grpc/grpc_client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ func slowRequest(ctx context.Context, method string, req, reply interface{}, cc
235235
return err
236236
}
237237

238+
//nolint:deadcode,unused
238239
func timeoutRequest(ctx context.Context, method string, req, reply interface{},
239240
cc *grpc.ClientConn,
240241
invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {

grpc/grpc_client_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloRe
2828
}
2929

3030
func TestMain(m *testing.M) {
31-
3231
logger = log.NewLogger()
3332

3433
lis, err := net.Listen("tcp", "0.0.0.0:50051")
@@ -77,7 +76,6 @@ func TestMain(m *testing.M) {
7776
}
7877

7978
func TestNewGrpcClient(t *testing.T) {
80-
8179
memConfig := config.NewMemConfig()
8280
memConfig.Set("debug", true)
8381
memConfig.Set("grpc_client_debug", true)
@@ -106,7 +104,6 @@ func TestNewGrpcClient(t *testing.T) {
106104
}
107105

108106
func TestSlowClient(t *testing.T) {
109-
110107
memConfig := config.NewMemConfig()
111108
memConfig.Set("debug", true)
112109
memConfig.Set("grpc_client_debug", true)
@@ -141,7 +138,6 @@ func TestSlowClient(t *testing.T) {
141138
}
142139

143140
func TestServerPanic(t *testing.T) {
144-
145141
svr.unaryServerInterceptors = append(svr.unaryServerInterceptors, panicResp())
146142

147143
memConfig := config.NewMemConfig()
@@ -169,7 +165,6 @@ func TestServerPanic(t *testing.T) {
169165
}
170166

171167
func TestServerPanicArr(t *testing.T) {
172-
173168
memConfig := config.NewMemConfig()
174169
memConfig.Set("debug", true)
175170
memConfig.Set("grpc_client_debug", true)
@@ -195,7 +190,6 @@ func TestServerPanicArr(t *testing.T) {
195190
}
196191

197192
func TestSubsReply(t *testing.T) {
198-
199193
memConfig := config.NewMemConfig()
200194
memConfig.Set("debug", true)
201195
memConfig.Set("grpc_client_debug", true)

grpc/grpc_server.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ type ServerOption func(c *Server)
4444
type ServerOptions struct{}
4545

4646
func NewServer(target string, options ...ServerOption) *Server {
47-
4847
Server := &Server{}
4948

5049
Server.target = target
@@ -221,6 +220,7 @@ func (gs *Server) handelPanic() grpc_recovery.RecoveryHandlerFuncContext {
221220
}
222221
}
223222

223+
//nolint:deadcode,unused
224224
func nilResp() grpc.UnaryServerInterceptor {
225225
return func(
226226
ctx context.Context,
@@ -271,7 +271,6 @@ func ServerStubs(stubsFunc func(
271271
}
272272

273273
func (gs *Server) Start() {
274-
275274
lis, err := net.Listen("tcp", gs.target)
276275
if err != nil {
277276
gs.logger.Panicf("failed to listen: %s", err.Error())

http/http.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ type Option func(c *Client)
2525
type ClientOptions struct{}
2626

2727
func NewClient(options ...Option) *Client {
28-
2928
Client := &Client{
3029
transports: make([]func() interface{}, 0),
3130
}

0 commit comments

Comments
 (0)