diff options
author | Thomas Voss <mail@thomasvoss.com> | 2025-06-14 00:41:27 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2025-06-14 00:41:27 +0200 |
commit | 4f14515613bd491dd0627398aa8fc3e3aef07945 (patch) | |
tree | 61d7ad4890707b280c15118c47281a02dc5000f7 /src/atexit | |
parent | 604cac8c0ab26a43d28341ff6f6e58e969eec925 (diff) |
Implement the ‘atexit’ package
Diffstat (limited to 'src/atexit')
-rw-r--r-- | src/atexit/atexit.go | 13 |
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]() + } +} |