From 8226f476674d0ff899c3ef4a252c8bf337ea11bf Mon Sep 17 00:00:00 2001 From: dingjun Date: Mon, 15 Apr 2019 15:53:26 +0800 Subject: [PATCH] fix filename issue in go module mode --- util_fileline.go | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/util_fileline.go b/util_fileline.go index b13ec16..bc7cf3d 100644 --- a/util_fileline.go +++ b/util_fileline.go @@ -14,23 +14,11 @@ func FilelineCaller(skip int) (file string, line int) { return "???", 0 } - //fmt.Printf("%s:%d\n", file, line) - if strings.Contains(file, "go-log/") { + // in go module mode, the import path like this + // github.com/fangdingjun/go-log@v4.0.1-incomple/ + if strings.Contains(file, "go-log/") || strings.Contains(file, "go-log@v") { continue } - /* - // file = pkg/file.go - n := 0 - for i := len(file) - 1; i > 0; i-- { - if file[i] == '/' { - n++ - if n >= 2 { - file = file[i+1:] - break - } - } - } - */ return path.Base(file), line }