We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2f6783c commit 13faa5cCopy full SHA for 13faa5c
src/cmd/go/internal/base/base.go
@@ -104,16 +104,23 @@ func (c *Command) Runnable() bool {
104
return c.Run != nil
105
}
106
107
-var atExitFuncs []func()
+var (
108
+ atExitFuncsLock sync.Mutex
109
+ atExitFuncs []func()
110
+)
111
112
func AtExit(f func()) {
113
+ atExitFuncsLock.Lock()
114
+ defer atExitFuncsLock.Unlock()
115
atExitFuncs = append(atExitFuncs, f)
116
117
118
func Exit() {
119
120
for _, f := range atExitFuncs {
121
f()
122
123
+ atExitFuncsLock.Unlock()
124
os.Exit(exitStatus)
125
126
0 commit comments