Skip to content

Commit e21e309

Browse files
committed
Fix some lint
1 parent ff10a9b commit e21e309

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

.github/workflows/lint.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ jobs:
1111
steps:
1212
- name: Checkout code
1313
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
14+
- name: Update Go
15+
uses: actions/setup-go@v4
16+
with:
17+
go-version: '>=1.21.0'
18+
cache: false
1419
- name: Lint
1520
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
1621
with:

sloghandler.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (l *slogHandler) GetLevel() slog.Level {
5252
return l.levelBias
5353
}
5454

55-
func (l *slogHandler) Enabled(ctx context.Context, level slog.Level) bool {
55+
func (l *slogHandler) Enabled(_ context.Context, level slog.Level) bool {
5656
return l.sink != nil && (level >= slog.LevelError || l.sink.Enabled(l.levelFromSlog(level)))
5757
}
5858

@@ -107,34 +107,34 @@ func (l *slogHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
107107
return l
108108
}
109109

110-
copy := *l
110+
clone := *l
111111
if l.slogSink != nil {
112-
copy.slogSink = l.slogSink.WithAttrs(attrs)
113-
copy.sink = copy.slogSink
112+
clone.slogSink = l.slogSink.WithAttrs(attrs)
113+
clone.sink = clone.slogSink
114114
} else {
115115
kvList := make([]any, 0, 2*len(attrs))
116116
for _, attr := range attrs {
117117
if attr.Key != "" {
118118
kvList = append(kvList, l.addGroupPrefix(attr.Key), attr.Value.Resolve().Any())
119119
}
120120
}
121-
copy.sink = l.sink.WithValues(kvList...)
121+
clone.sink = l.sink.WithValues(kvList...)
122122
}
123-
return &copy
123+
return &clone
124124
}
125125

126126
func (l *slogHandler) WithGroup(name string) slog.Handler {
127127
if l.sink == nil {
128128
return l
129129
}
130-
copy := *l
130+
clone := *l
131131
if l.slogSink != nil {
132-
copy.slogSink = l.slogSink.WithGroup(name)
133-
copy.sink = copy.slogSink
132+
clone.slogSink = l.slogSink.WithGroup(name)
133+
clone.sink = clone.slogSink
134134
} else {
135-
copy.groupPrefix = copy.addGroupPrefix(name)
135+
clone.groupPrefix = clone.addGroupPrefix(name)
136136
}
137-
return &copy
137+
return &clone
138138
}
139139

140140
func (l *slogHandler) addGroupPrefix(name string) string {

slogr_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ func containsOne(hay string, needles ...string) bool {
218218
return false
219219
}
220220

221-
func TestDiscard(t *testing.T) {
221+
func TestDiscard(_ *testing.T) {
222+
// Compile-test
222223
logger := slog.New(logr.ToSlogHandler(logr.Discard()))
223224
logger.WithGroup("foo").With("x", 1).Info("hello")
224225
}

slogsink.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ func (l *slogSink) log(err error, msg string, level slog.Level, kvList ...interf
9191
record.AddAttrs(slog.Any(errKey, err))
9292
}
9393
record.Add(kvList...)
94-
l.handler.Handle(context.Background(), record)
94+
_ = l.handler.Handle(context.Background(), record)
9595
}
9696

9797
func (l slogSink) WithName(name string) LogSink {
9898
if l.name != "" {
99-
l.name = l.name + "/"
99+
l.name += "/"
100100
}
101101
l.name += name
102102
return &l

0 commit comments

Comments
 (0)