Check that there is a directory before trying to access it.

pull/443/head
Peter Ebden 2017-02-19 19:35:12 +00:00 committed by Davide D'Agostino
parent 18cfa6871f
commit 158f9d0389
1 changed files with 5 additions and 3 deletions

View File

@ -116,10 +116,12 @@ func CallerInfo() []string {
}
parts := strings.Split(file, "/")
dir := parts[len(parts)-2]
file = parts[len(parts)-1]
if (dir != "assert" && dir != "mock" && dir != "require") || file == "mock_test.go" {
callers = append(callers, fmt.Sprintf("%s:%d", file, line))
if len(parts) > 1 {
dir := parts[len(parts)-2]
if (dir != "assert" && dir != "mock" && dir != "require") || file == "mock_test.go" {
callers = append(callers, fmt.Sprintf("%s:%d", file, line))
}
}
// Drop the package