mirror of
https://github.com/pkg/errors.git
synced 2025-05-31 11:42:45 +00:00
Updates from code review.
This commit is contained in:
parent
665006faab
commit
046fc1474d
@ -91,15 +91,15 @@ func (l loc) Location() (string, int) {
|
|||||||
// leading separator.
|
// leading separator.
|
||||||
const sep = "/"
|
const sep = "/"
|
||||||
goal := strings.Count(fn.Name(), sep) + 2
|
goal := strings.Count(fn.Name(), sep) + 2
|
||||||
pathCnt := 0
|
|
||||||
i := len(file)
|
i := len(file)
|
||||||
for pathCnt < goal {
|
for n := 0; n < goal; n++ {
|
||||||
i = strings.LastIndex(file[:i], sep)
|
i = strings.LastIndex(file[:i], sep)
|
||||||
if i == -1 {
|
if i == -1 {
|
||||||
|
// not enough separators found, set i so that the slice expression
|
||||||
|
// below leaves file unmodified
|
||||||
i = -len(sep)
|
i = -len(sep)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
pathCnt++
|
|
||||||
}
|
}
|
||||||
// get back to 0 or trim the leading seperator
|
// get back to 0 or trim the leading seperator
|
||||||
file = file[i+len(sep):]
|
file = file[i+len(sep):]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user