We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 665006f commit 046fc14Copy full SHA for 046fc14
1 file changed
errors.go
@@ -91,15 +91,15 @@ func (l loc) Location() (string, int) {
91
// leading separator.
92
const sep = "/"
93
goal := strings.Count(fn.Name(), sep) + 2
94
- pathCnt := 0
95
i := len(file)
96
- for pathCnt < goal {
+ for n := 0; n < goal; n++ {
97
i = strings.LastIndex(file[:i], sep)
98
if i == -1 {
+ // not enough separators found, set i so that the slice expression
99
+ // below leaves file unmodified
100
i = -len(sep)
101
break
102
}
- pathCnt++
103
104
// get back to 0 or trim the leading seperator
105
file = file[i+len(sep):]
0 commit comments