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 <public@nlowe.me>
This commit is contained in:
Nathan Lowe 2019-07-21 22:30:17 -04:00
parent 893de67eb9
commit b4e169db26
No known key found for this signature in database
GPG Key ID: 1091439964459621

View File

@ -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)