From 046fc1474d6e1ace7eea71434c0d96f0685a2d6f Mon Sep 17 00:00:00 2001 From: Chris Hines Date: Sun, 24 Apr 2016 21:36:07 -0400 Subject: [PATCH] Updates from code review. --- errors.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/errors.go b/errors.go index b098f60..30b5885 100644 --- a/errors.go +++ b/errors.go @@ -91,15 +91,15 @@ func (l loc) Location() (string, int) { // leading separator. const sep = "/" goal := strings.Count(fn.Name(), sep) + 2 - pathCnt := 0 i := len(file) - for pathCnt < goal { + for n := 0; n < goal; n++ { i = strings.LastIndex(file[:i], sep) if i == -1 { + // not enough separators found, set i so that the slice expression + // below leaves file unmodified i = -len(sep) break } - pathCnt++ } // get back to 0 or trim the leading seperator file = file[i+len(sep):]