File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ func (c *closer) Add(f CloseFn) {
108108 }
109109
110110 for ! c .funcs .CompareAndSwap (old , & funcs ) {
111- old : = c .funcs .Load ()
111+ old = c .funcs .Load ()
112112 if old != nil {
113113 funcs = make ([]CloseFn , len (* old )+ 1 )
114114 copy (funcs , * old )
@@ -136,16 +136,19 @@ func (c *closer) CloseAll() {
136136 defer close (c .done )
137137
138138 ctx := context .WithoutCancel (* c .ctx .Load ())
139- funcs := * c .funcs .Swap (nil )
139+ funcs := c .funcs .Swap (nil )
140+ if funcs == nil {
141+ return
142+ }
140143
141- errCh := make (chan error , len (funcs ))
142- for _ , fn := range funcs {
144+ errCh := make (chan error , len (* funcs ))
145+ for _ , fn := range * funcs {
143146 go func (fn CloseFn ) {
144147 errCh <- fn (ctx )
145148 }(fn )
146149 }
147150
148- errs := make ([]error , 0 , len (funcs ))
151+ errs := make ([]error , 0 , len (* funcs ))
149152 for i := 0 ; i < cap (errs ); i ++ {
150153 if err := <- errCh ; err != nil {
151154 errs = append (errs , err )
You can’t perform that action at this time.
0 commit comments