commands/commands.go: use fmt to concat strings

In the logPanicToWriter() method a "le" variable containing
an OS-specific line ending string (e.g., "\n" on Unix/Linux)
is prepended and appended to various strings using the
string concatentation operator.  However, all these instances
occur within fmt.Fprint() and fmt.Fprintf() calls, so we can
simply use those tools to perform the concatenations.

These changes will reduce the changes needed in a subsequent
commit when we make some of these strings translatable.
This commit is contained in:
Chris Darroch 2022-01-28 19:38:01 -08:00
parent 816857ecfe
commit c8d12038b6

@ -482,8 +482,8 @@ func logPanicToWriter(w io.Writer, loggedError error, le string) {
gitV = "Error getting Git version: " + err.Error()
}
fmt.Fprint(w, config.VersionDesc+le)
fmt.Fprint(w, gitV+le)
fmt.Fprint(w, config.VersionDesc, le)
fmt.Fprint(w, gitV, le)
// log the command that was run
fmt.Fprint(w, le)
@ -497,26 +497,26 @@ func logPanicToWriter(w io.Writer, loggedError error, le string) {
w.Write(ErrorBuffer.Bytes())
fmt.Fprint(w, le)
fmt.Fprintf(w, "%+v"+le, loggedError)
fmt.Fprintf(w, "%+v%s", loggedError, le)
for key, val := range errors.Context(err) {
fmt.Fprintf(w, "%s=%v"+le, key, val)
fmt.Fprintf(w, "%s=%v%s", key, val, le)
}
fmt.Fprint(w, le+"Current time in UTC: "+le)
fmt.Fprint(w, time.Now().UTC().Format("2006-01-02 15:04:05")+le)
fmt.Fprint(w, le, "Current time in UTC:", le)
fmt.Fprint(w, time.Now().UTC().Format("2006-01-02 15:04:05"), le)
fmt.Fprint(w, le+"Environment:"+le)
fmt.Fprint(w, le, "Environment:", le)
// log the environment
for _, env := range lfs.Environ(cfg, getTransferManifest(), oldEnv) {
fmt.Fprint(w, env+le)
fmt.Fprint(w, env, le)
}
fmt.Fprint(w, le+"Client IP addresses:"+le)
fmt.Fprint(w, le, "Client IP addresses:", le)
for _, ip := range ipAddresses() {
fmt.Fprint(w, ip+le)
fmt.Fprint(w, ip, le)
}
}