Skip to content

Commit b0307c0

Browse files
committed
cleanup for golang linter QF1012
Signed-off-by: Kay Yan <[email protected]>
1 parent 1d88823 commit b0307c0

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

.golangci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ linters:
5353
- "-ST1022"
5454

5555
##### TODO: fix and enable these
56-
# 4 occurrences.
57-
# Use fmt.Fprintf(x, ...) instead of x.Write(fmt.Sprintf(...)) https://staticcheck.dev/docs/checks#QF1012
58-
- "-QF1012"
5956
# 6 occurrences.
6057
# Apply De Morgan’s law https://staticcheck.dev/docs/checks#QF1001
6158
- "-QF1001"

pkg/logging/cri_logger_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,12 @@ func TestReadLogsLimitsWithTimestamps(t *testing.T) {
184184
count := 10000
185185

186186
for i := 0; i < count; i++ {
187-
tmpfile.WriteString(fmt.Sprintf(logLineFmt, i))
187+
fmt.Fprintf(tmpfile, logLineFmt, i)
188188
}
189189
tmpfile.WriteString(logLineNewLine)
190190

191191
for i := 0; i < count; i++ {
192-
tmpfile.WriteString(fmt.Sprintf(logLineFmt, i))
192+
fmt.Fprintf(tmpfile, logLineFmt, i)
193193
}
194194
tmpfile.WriteString(logLineNewLine)
195195

@@ -271,11 +271,10 @@ func TestReadRotatedLog(t *testing.T) {
271271
// Write the first three lines to log file
272272
now := time.Now().Format(time.RFC3339Nano)
273273
if line%2 == 0 {
274-
file.WriteString(fmt.Sprintf(
275-
"%s stdout P line%d\n", now, line))
274+
fmt.Fprintf(file, "%s stdout P line%d\n", now, line)
275+
276276
} else {
277-
file.WriteString(fmt.Sprintf(
278-
"%s stderr P line%d\n", now, line))
277+
fmt.Fprintf(file, "%s stderr P line%d\n", now, line)
279278
}
280279

281280
time.Sleep(1 * time.Millisecond)

0 commit comments

Comments
 (0)