Skip to content

Commit

Permalink
fix cropFilename
Browse files Browse the repository at this point in the history
  • Loading branch information
nikandfor committed Aug 25, 2024
1 parent 4e1d1d5 commit f3c762c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion location.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func CallersFill(skip int, tr PCs) PCs {
func cropFilename(fn, tp string) string {
p := strings.LastIndexByte(tp, '/')
pp := strings.IndexByte(tp[p+1:], '.')
tp = tp[:p+pp] // cut type and func name
tp = tp[:p+1+pp] // cut type and func name

for {
if p = strings.LastIndex(fn, tp); p != -1 {
Expand Down
1 change: 1 addition & 0 deletions location_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func TestLocationCropFileName(t *testing.T) {
assert.Equal(t, "subpkg/file.go", cropFilename("/path/to/src/subpkg/file.go", "github.com/nikandfor/tlog/subpkg.(*type).method"))
assert.Equal(t, "errors/fmt_test.go",
cropFilename("/home/runner/work/errors/errors/fmt_test.go", "tlog.app/go/error.TestErrorFormatCaller"))
assert.Equal(t, "jq/object_test.go", cropFilename("/Users/nik/nikandfor/jq/object_test.go", "nikand.dev/go/jq.TestObject"))
}

func TestCaller(t *testing.T) {
Expand Down

0 comments on commit f3c762c

Please sign in to comment.