Skip to content

Commit 0e3ceee

Browse files
committed
fix: use fmt.Fprintf instead of WriteString(fmt.Sprintf) in healthcheck
1 parent b97e22b commit 0e3ceee

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

runner/healthcheck.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ func DoHealthCheck(options *Options, flagSet *goflags.FlagSet) string {
1414
// RW permissions on config file
1515
cfgFilePath, _ := flagSet.GetConfigFilePath()
1616
var test strings.Builder
17-
test.WriteString(fmt.Sprintf("Version: %s\n", Version))
18-
test.WriteString(fmt.Sprintf("Operative System: %s\n", runtime.GOOS))
19-
test.WriteString(fmt.Sprintf("Architecture: %s\n", runtime.GOARCH))
20-
test.WriteString(fmt.Sprintf("Go Version: %s\n", runtime.Version()))
21-
test.WriteString(fmt.Sprintf("Compiler: %s\n", runtime.Compiler))
17+
fmt.Fprintf(&test, "Version: %s\n", Version)
18+
fmt.Fprintf(&test, "Operative System: %s\n", runtime.GOOS)
19+
fmt.Fprintf(&test, "Architecture: %s\n", runtime.GOARCH)
20+
fmt.Fprintf(&test, "Go Version: %s\n", runtime.Version())
21+
fmt.Fprintf(&test, "Compiler: %s\n", runtime.Compiler)
2222

2323
var testResult string
2424
ok, err := fileutil.IsReadable(cfgFilePath)
@@ -30,7 +30,7 @@ func DoHealthCheck(options *Options, flagSet *goflags.FlagSet) string {
3030
if err != nil {
3131
testResult += fmt.Sprintf(" (%s)", err)
3232
}
33-
test.WriteString(fmt.Sprintf("Config file \"%s\" Read => %s\n", cfgFilePath, testResult))
33+
fmt.Fprintf(&test, "Config file \"%s\" Read => %s\n", cfgFilePath, testResult)
3434
ok, err = fileutil.IsWriteable(cfgFilePath)
3535
if ok {
3636
testResult = "Ok"
@@ -40,7 +40,7 @@ func DoHealthCheck(options *Options, flagSet *goflags.FlagSet) string {
4040
if err != nil {
4141
testResult += fmt.Sprintf(" (%s)", err)
4242
}
43-
test.WriteString(fmt.Sprintf("Config file \"%s\" Write => %s\n", cfgFilePath, testResult))
43+
fmt.Fprintf(&test, "Config file \"%s\" Write => %s\n", cfgFilePath, testResult)
4444
c4, err := net.Dial("tcp4", "scanme.sh:80")
4545
if err == nil && c4 != nil {
4646
_ = c4.Close()
@@ -49,7 +49,7 @@ func DoHealthCheck(options *Options, flagSet *goflags.FlagSet) string {
4949
if err != nil {
5050
testResult = fmt.Sprintf("Ko (%s)", err)
5151
}
52-
test.WriteString(fmt.Sprintf("IPv4 connectivity to scanme.sh:80 => %s\n", testResult))
52+
fmt.Fprintf(&test, "IPv4 connectivity to scanme.sh:80 => %s\n", testResult)
5353
c6, err := net.Dial("tcp6", "scanme.sh:80")
5454
if err == nil && c6 != nil {
5555
_ = c6.Close()
@@ -58,7 +58,7 @@ func DoHealthCheck(options *Options, flagSet *goflags.FlagSet) string {
5858
if err != nil {
5959
testResult = fmt.Sprintf("Ko (%s)", err)
6060
}
61-
test.WriteString(fmt.Sprintf("IPv6 connectivity to scanme.sh:80 => %s\n", testResult))
61+
fmt.Fprintf(&test, "IPv6 connectivity to scanme.sh:80 => %s\n", testResult)
6262

6363
return test.String()
6464
}

0 commit comments

Comments
 (0)