summaryrefslogtreecommitdiffhomepage
path: root/src/atexit
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2025-06-14 00:41:27 +0200
committerThomas Voss <mail@thomasvoss.com> 2025-06-14 00:41:27 +0200
commit4f14515613bd491dd0627398aa8fc3e3aef07945 (patch)
tree61d7ad4890707b280c15118c47281a02dc5000f7 /src/atexit
parent604cac8c0ab26a43d28341ff6f6e58e969eec925 (diff)
Implement the ‘atexit’ package
Diffstat (limited to 'src/atexit')
-rw-r--r--src/atexit/atexit.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/atexit/atexit.go b/src/atexit/atexit.go
new file mode 100644
index 0000000..ed35ccf
--- /dev/null
+++ b/src/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]()
+ }
+}