Skip to content

Commit f89373c

Browse files
authored
fix linter issue with go1.24: distiguish writeBuf and writeBuff (#346)
Linter error was: cmd/flow_display.go:199:13: printf: non-constant format string in call to github.com/netobserv/network-observability-cli/cmd.writeBuf (govet) Using the conventional pattern of "func" vs "funcf" to distinguish function signatures with or without formatting/varg injection
1 parent 0426017 commit f89373c

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

cmd/flow_display.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -98,31 +98,31 @@ func updateTable() {
9898
writeBuf("\033[?7l")
9999
}
100100

101-
writeBuf("Running network-observability-cli as %s Capture\n", captureType)
102-
writeBuf("Log level: %s ", logLevel)
103-
writeBuf("Duration: %s ", currentTime().Sub(startupTime).Round(time.Second))
104-
writeBuf("Capture size: %s\n", sizestr.ToString(totalBytes))
101+
writeBuff("Running network-observability-cli as %s Capture\n", captureType)
102+
writeBuff("Log level: %s ", logLevel)
103+
writeBuff("Duration: %s ", currentTime().Sub(startupTime).Round(time.Second))
104+
writeBuff("Capture size: %s\n", sizestr.ToString(totalBytes))
105105
if len(strings.TrimSpace(options)) > 0 {
106-
writeBuf("Options: %s\n", options)
106+
writeBuff("Options: %s\n", options)
107107
}
108108

109109
if totalBytes > 0 {
110110
if strings.Contains(options, "background=true") {
111-
writeBuf("Showing last: %d\n", showCount)
112-
writeBuf("Display: %s\n", display.getCurrentItem().name)
113-
writeBuf("Enrichment: %s\n", enrichment.getCurrentItem().name)
111+
writeBuff("Showing last: %d\n", showCount)
112+
writeBuff("Display: %s\n", display.getCurrentItem().name)
113+
writeBuff("Enrichment: %s\n", enrichment.getCurrentItem().name)
114114
} else {
115-
writeBuf("Showing last: %d Use Up / Down keyboard arrows to increase / decrease limit\n", showCount)
116-
writeBuf("Display: %s Use Left / Right keyboard arrows to cycle views\n", display.getCurrentItem().name)
117-
writeBuf("Enrichment: %s Use Page Up / Page Down keyboard keys to cycle enrichment scopes\n", enrichment.getCurrentItem().name)
115+
writeBuff("Showing last: %d Use Up / Down keyboard arrows to increase / decrease limit\n", showCount)
116+
writeBuff("Display: %s Use Left / Right keyboard arrows to cycle views\n", display.getCurrentItem().name)
117+
writeBuff("Enrichment: %s Use Page Up / Page Down keyboard keys to cycle enrichment scopes\n", enrichment.getCurrentItem().name)
118118
}
119119

120120
if display.getCurrentItem().name == rawDisplay {
121121
outputBuffer.WriteString("Raw flow logs:\n")
122122
for _, flow := range lastFlows {
123-
writeBuf("%v\n", flow)
123+
writeBuff("%v\n", flow)
124124
}
125-
writeBuf("%s\n", strings.Repeat("-", 500))
125+
writeBuff("%s\n", strings.Repeat("-", 500))
126126
} else {
127127
// recreate table from scratch
128128
headerFmt := color.New(color.BgHiBlue, color.Bold).SprintfFunc()
@@ -199,7 +199,7 @@ func updateTable() {
199199
writeBuf(keyboardError)
200200
} else {
201201
if len(regexes) > 0 {
202-
writeBuf("Live table filter: %s Press enter to match multiple regexes at once\n", regexes)
202+
writeBuff("Live table filter: %s Press enter to match multiple regexes at once\n", regexes)
203203
} else {
204204
writeBuf("Type anything to filter incoming flows in view\n")
205205
}
@@ -213,12 +213,12 @@ func updateTable() {
213213
}
214214
}
215215

216-
func writeBuf(s string, a ...any) {
217-
if len(a) > 0 {
218-
fmt.Fprintf(outputBuffer, s, a...)
219-
} else {
220-
outputBuffer.WriteString(s)
221-
}
216+
func writeBuf(s string) {
217+
outputBuffer.WriteString(s)
218+
}
219+
220+
func writeBuff(s string, a ...any) {
221+
fmt.Fprintf(outputBuffer, s, a...)
222222
}
223223

224224
func printBuf() {

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module github.com/netobserv/network-observability-cli
22

3-
go 1.23.0
3+
go 1.24.0
44

5-
toolchain go1.23.5
5+
toolchain go1.24.4
66

77
require (
88
github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203

0 commit comments

Comments
 (0)