Use Cleanup to remove old entries in ts map

This commit is contained in:
Nise Void 2020-05-12 18:00:07 +02:00
parent fe8a28286e
commit d20ac9444a
Signed by: NiseVoid
GPG Key ID: FBA14AC83EA602F3
2 changed files with 5 additions and 0 deletions

View File

@ -24,6 +24,10 @@ func New(t T) Assert {
f := runtime.FuncForPC(reflect.ValueOf(a).Pointer())
ts[f] = t
t.Cleanup(func() {
delete(ts, f)
})
return a
}

View File

@ -4,4 +4,5 @@ package assert
type T interface {
Error(...interface{})
Helper()
Cleanup(func())
}