Skip to content

Commit 5d506e6

Browse files
lvan100lianghuan
authored andcommitted
refactor(log): remove unnecessary go-loop package
1 parent 856a45a commit 5d506e6

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ go 1.24
55
require (
66
github.com/expr-lang/expr v1.17.2
77
github.com/lvan100/go-assert v0.0.2
8-
github.com/lvan100/go-loop v0.0.2
98
github.com/magiconair/properties v1.8.10
109
github.com/pelletier/go-toml v1.9.5
1110
github.com/spf13/cast v1.7.1

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
1010
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
1111
github.com/lvan100/go-assert v0.0.2 h1:K1G++zfdM5h+1Q/hSctEEqqcJIOs327k2kLiO3MmE5E=
1212
github.com/lvan100/go-assert v0.0.2/go.mod h1:osFFuU9zt4/SdTaJ9uU3y9qabAFDYlaH4Yte/ndDAj4=
13-
github.com/lvan100/go-loop v0.0.2 h1:FPy0gCO4jjWrNeJazTtIDH1HgKogK4HkTgplXMa0mu4=
14-
github.com/lvan100/go-loop v0.0.2/go.mod h1:xlhZBgRA1uBEDGsxTgWy3r7Ab04J/gbVYc2wHNKTv6w=
1513
github.com/magiconair/properties v1.8.10 h1:s31yESBquKXCV9a/ScB3ESkOjUYYv+X0rg8SYxI99mE=
1614
github.com/magiconair/properties v1.8.10/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
1715
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=

log/log_refresh.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func RefreshFile(fileName string) error {
3838
if err != nil {
3939
return err
4040
}
41+
// nolint: errcheck
4142
defer file.Close()
4243
ext := filepath.Ext(fileName)
4344
return RefreshReader(file, ext)

log/log_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ import (
2525
"github.com/lvan100/go-assert"
2626
)
2727

28+
const TraceID = "trace_id"
29+
const SpanID = "span_id"
30+
2831
var TagDefault = log.GetTag("_def")
2932
var TagRequestIn = log.GetTag("_com_request_in")
3033
var TagRequestOut = log.GetTag("_com_request_out")
@@ -41,11 +44,11 @@ func TestLog(t *testing.T) {
4144
}
4245

4346
log.FieldsFromContext = func(ctx context.Context) []log.Field {
44-
traceID, _ := ctx.Value("trace_id").(string)
45-
spanID, _ := ctx.Value("span_id").(string)
47+
traceID, _ := ctx.Value(TraceID).(string)
48+
spanID, _ := ctx.Value(SpanID).(string)
4649
return []log.Field{
47-
log.String("trace_id", traceID),
48-
log.String("span_id", spanID),
50+
log.String(TraceID, traceID),
51+
log.String(SpanID, spanID),
4952
}
5053
}
5154

@@ -61,8 +64,8 @@ func TestLog(t *testing.T) {
6164
err := log.RefreshFile("testdata/log.xml")
6265
assert.Nil(t, err)
6366

64-
ctx = context.WithValue(ctx, "trace_id", "0a882193682db71edd48044db54cae88")
65-
ctx = context.WithValue(ctx, "span_id", "50ef0724418c0a66")
67+
ctx = context.WithValue(ctx, TraceID, "0a882193682db71edd48044db54cae88")
68+
ctx = context.WithValue(ctx, SpanID, "50ef0724418c0a66")
6669

6770
log.Trace(ctx, TagRequestOut, func() []log.Field {
6871
return []log.Field{

0 commit comments

Comments
 (0)