summaryrefslogtreecommitdiffhomepage
path: root/pkg/atexit/atexit.go
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2025-06-14 00:45:04 +0200
committerThomas Voss <mail@thomasvoss.com> 2025-06-14 00:45:04 +0200
commitfe2bae01c6b14eef0e61cd4a6bd50e814de4bb58 (patch)
tree60fbda65d5fa3a9afc966bce51b6968e966baf4c /pkg/atexit/atexit.go
parent2d5ca3a6cd507ef29eb13b3a78232264a2817e81 (diff)
Move some packages to pkg/
Diffstat (limited to 'pkg/atexit/atexit.go')
-rw-r--r--pkg/atexit/atexit.go13
1 files changed, 13 insertions, 0 deletions
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]()
+ }
+}