Skip to content

Commit 56ae907

Browse files
committed
refactor: use _ to discard fmt.Fprintf return value
Signed-off-by: yxxhero <aiopsclub@163.com>
1 parent 348b9ac commit 56ae907

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

.golangci.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ run:
5151

5252
# output configuration options
5353
output:
54+
formats:
5455
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
55-
format: line-number
56+
- format: line-number
5657

5758
# print lines of code with issue, default is true
5859
print-issued-lines: true

diff/diff.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,14 +363,14 @@ func printDiffRecord(diff difflib.DiffRecord, to io.Writer) {
363363

364364
switch diff.Delta {
365365
case difflib.RightOnly:
366-
fmt.Fprintf(to, "%s\n", ansi.Color("+ "+text, "green"))
366+
_, _ = fmt.Fprintf(to, "%s\n", ansi.Color("+ "+text, "green"))
367367
case difflib.LeftOnly:
368-
fmt.Fprintf(to, "%s\n", ansi.Color("- "+text, "red"))
368+
_, _ = fmt.Fprintf(to, "%s\n", ansi.Color("- "+text, "red"))
369369
case difflib.Common:
370370
if text == "" {
371371
fmt.Fprintln(to)
372372
} else {
373-
fmt.Fprintf(to, "%s\n", " "+text)
373+
_, _ = fmt.Fprintf(to, "%s\n", " "+text)
374374
}
375375
}
376376
}

diff/report.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func setupDiffReport(r *Report) {
148148
// print report for default output: diff
149149
func printDiffReport(r *Report, to io.Writer) {
150150
for _, entry := range r.entries {
151-
fmt.Fprintf(to, ansi.Color("%s %s", "yellow")+"\n", entry.key, r.format.changestyles[entry.changeType].message)
151+
_, _ = fmt.Fprintf(to, ansi.Color("%s %s", "yellow")+"\n", entry.key, r.format.changestyles[entry.changeType].message)
152152
printDiffRecords(entry.suppressedKinds, entry.kind, entry.context, entry.diffs, to)
153153
}
154154
}
@@ -170,13 +170,13 @@ func printSimpleReport(r *Report, to io.Writer) {
170170
"MODIFY": 0,
171171
}
172172
for _, entry := range r.entries {
173-
fmt.Fprintf(to, ansi.Color("%s %s", r.format.changestyles[entry.changeType].color)+"\n",
173+
_, _ = fmt.Fprintf(to, ansi.Color("%s %s", r.format.changestyles[entry.changeType].color)+"\n",
174174
entry.key,
175175
r.format.changestyles[entry.changeType].message,
176176
)
177177
summary[entry.changeType]++
178178
}
179-
fmt.Fprintf(to, "Plan: %d to add, %d to change, %d to destroy.\n", summary["ADD"], summary["MODIFY"], summary["REMOVE"])
179+
_, _ = fmt.Fprintf(to, "Plan: %d to add, %d to change, %d to destroy.\n", summary["ADD"], summary["MODIFY"], summary["REMOVE"])
180180
}
181181

182182
func newTemplate(name string) *template.Template {

main_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func runFakeHelm() int {
9090
}
9191

9292
if stub == nil {
93-
fmt.Fprintf(os.Stderr, "no stub for %s\n", cmdAndArgs)
93+
_, _ = fmt.Fprintf(os.Stderr, "no stub for %s\n", cmdAndArgs)
9494
return 1
9595
}
9696

@@ -100,13 +100,13 @@ func runFakeHelm() int {
100100
}
101101
got := cmdAndArgs[len(stub.cmd):]
102102
if !reflect.DeepEqual(want, got) {
103-
fmt.Fprintf(os.Stderr, "want: %v\n", want)
104-
fmt.Fprintf(os.Stderr, "got : %v\n", got)
105-
fmt.Fprintf(os.Stderr, "args : %v\n", os.Args)
106-
fmt.Fprintf(os.Stderr, "env : %v\n", os.Environ())
103+
_, _ = fmt.Fprintf(os.Stderr, "want: %v\n", want)
104+
_, _ = fmt.Fprintf(os.Stderr, "got : %v\n", got)
105+
_, _ = fmt.Fprintf(os.Stderr, "args : %v\n", os.Args)
106+
_, _ = fmt.Fprintf(os.Stderr, "env : %v\n", os.Environ())
107107
return 1
108108
}
109-
fmt.Fprintf(os.Stdout, "%s", stub.stdout)
110-
fmt.Fprintf(os.Stderr, "%s", stub.stderr)
109+
_, _ = fmt.Fprintf(os.Stdout, "%s", stub.stdout)
110+
_, _ = fmt.Fprintf(os.Stderr, "%s", stub.stderr)
111111
return stub.exitCode
112112
}

0 commit comments

Comments
 (0)