diff --git a/gleak/goroutine/goroutine.go b/gleak/goroutine/goroutine.go index e321ead56..d797ca924 100644 --- a/gleak/goroutine/goroutine.go +++ b/gleak/goroutine/goroutine.go @@ -33,6 +33,7 @@ import ( // - "copystack" // - "preempted" // - ("???" ... something IS severely broken.) +// // In case a goroutine is in waiting state, the State field instead starts with // one of the following strings, never showing a lonely "waiting" string, but // rather one of the reasons for waiting: @@ -176,6 +177,9 @@ func findCreator(backtrace string) (creator, location string) { } location = strings.TrimSpace(details[1][:offsetpos]) creator = details[0] + if offsetpos := strings.LastIndex(creator, " in goroutine "); offsetpos >= 0 { + creator = creator[:offsetpos] + } return } diff --git a/gleak/ignoring_creator_test.go b/gleak/ignoring_creator_test.go index 7b5f5cb72..f7ddbec2a 100644 --- a/gleak/ignoring_creator_test.go +++ b/gleak/ignoring_creator_test.go @@ -27,9 +27,11 @@ var _ = Describe("IgnoringCreator matcher", func() { It("matches a creator function by full name", func() { type T struct{} pkg := reflect.TypeOf(T{}).PkgPath() - m := IgnoringCreator(pkg + ".creator") + ignore := pkg + ".creator" + m := IgnoringCreator(ignore) g := creator() - Expect(m.Match(g)).To(BeTrue(), "creator %v", g.String()) + Expect(m.Match(g)).To(BeTrue(), "creator: %v\ntried to ignore: %s", + g.String(), ignore) Expect(m.Match(goroutine.Current())).To(BeFalse()) })