From fe2bae01c6b14eef0e61cd4a6bd50e814de4bb58 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sat, 14 Jun 2025 00:45:04 +0200 Subject: Move some packages to pkg/ --- pkg/atexit/atexit.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 pkg/atexit/atexit.go (limited to 'pkg/atexit/atexit.go') diff --git a/pkg/atexit/atexit.go b/pkg/atexit/atexit.go new file mode 100644 index 0000000..ed35ccf --- /dev/null +++ b/pkg/atexit/atexit.go @@ -0,0 +1,13 @@ +package atexit + +var hooks = []func(){} + +func Register(f func()) { + hooks = append(hooks, f) +} + +func Exec() { + for i := len(hooks)-1; i >= 0; i-- { + hooks[i]() + } +} -- cgit v1.2.3