From 688014487bd432549154430d325e0598954d15de Mon Sep 17 00:00:00 2001 From: Alexander Bruyako Date: Mon, 27 Jan 2020 19:24:42 +0300 Subject: [PATCH] avoid "index out of range" error in case of len(format) == 0, we will get an "index out of range" error Usage of strings.HasSuffix is allowing to avoid that --- cmd/restic/global.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/restic/global.go b/cmd/restic/global.go index ef69eabc3..bfb8ba9e8 100644 --- a/cmd/restic/global.go +++ b/cmd/restic/global.go @@ -232,7 +232,7 @@ func Warnf(format string, args ...interface{}) { // Exitf uses Warnf to write the message and then terminates the process with // the given exit code. func Exitf(exitcode int, format string, args ...interface{}) { - if format[len(format)-1] != '\n' { + if !(strings.HasSuffix(format, "\n")) { format += "\n" }