mirror of
https://github.com/restic/restic.git
synced 2025-08-14 00:57:40 +00:00
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
This commit is contained in:
@@ -232,7 +232,7 @@ func Warnf(format string, args ...interface{}) {
|
|||||||
// Exitf uses Warnf to write the message and then terminates the process with
|
// Exitf uses Warnf to write the message and then terminates the process with
|
||||||
// the given exit code.
|
// the given exit code.
|
||||||
func Exitf(exitcode int, format string, args ...interface{}) {
|
func Exitf(exitcode int, format string, args ...interface{}) {
|
||||||
if format[len(format)-1] != '\n' {
|
if !(strings.HasSuffix(format, "\n")) {
|
||||||
format += "\n"
|
format += "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user