octolab / pkg

🧰 Go packages.

Home Page:https://go.octolab.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

extend safe package by finalizers

kamilsk opened this issue · comments

https://golang.org/pkg/runtime/#SetFinalizer

file, err := safe.OpenFile()
if err ...
// no call defer file.Close()
// panic in runtime

how it works

Open() -> SetFinalizer

Close() -> UnsetFinalizer

also, the custom profiler can be usefull:

Open() -> profile.Add

Close() -> profile.Remove