Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.

Commit 046fc14

Browse files
committed
Updates from code review.
1 parent 665006f commit 046fc14

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

errors.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@ func (l loc) Location() (string, int) {
9191
// leading separator.
9292
const sep = "/"
9393
goal := strings.Count(fn.Name(), sep) + 2
94-
pathCnt := 0
9594
i := len(file)
96-
for pathCnt < goal {
95+
for n := 0; n < goal; n++ {
9796
i = strings.LastIndex(file[:i], sep)
9897
if i == -1 {
98+
// not enough separators found, set i so that the slice expression
99+
// below leaves file unmodified
99100
i = -len(sep)
100101
break
101102
}
102-
pathCnt++
103103
}
104104
// get back to 0 or trim the leading seperator
105105
file = file[i+len(sep):]

0 commit comments

Comments
 (0)