From b4e169db265b84e4b118d095e30654b93d17a24c Mon Sep 17 00:00:00 2001 From: Nathan Lowe Date: Sun, 21 Jul 2019 22:30:17 -0400 Subject: [PATCH] Fix logger line() call if built outside of the repo root If harbor is built (or `go test`'d) in a different folder than the repo root, the call to common/utils/log/line(...) will panic with an index out of range runtime error because the separator can't find `harbor/src` in the path. Signed-off-by: Nathan Lowe --- src/common/utils/log/logger.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/utils/log/logger.go b/src/common/utils/log/logger.go index 882f8a716..5c8b6b376 100644 --- a/src/common/utils/log/logger.go +++ b/src/common/utils/log/logger.go @@ -278,7 +278,7 @@ func line(callDepth int) string { line = 0 } l := strings.SplitN(file, srcSeparator, 2) - if len(l) > 0 { + if len(l) > 1 { file = l[1] } return fmt.Sprintf("[%s:%d]:", file, line)