File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ func CloseAll() {
6565func New (ctx context.Context , opts ... Option ) (context.Context , * closer ) {
6666 o := options {}
6767 for _ , opt := range opts {
68- opt (& o )
68+ o = opt (o )
6969 }
7070
7171 var cancel context.CancelFunc
Original file line number Diff line number Diff line change @@ -11,24 +11,22 @@ type options struct {
1111 ctxCancel bool
1212}
1313
14- type Option func (* options )
14+ type Option func (options ) options
1515
1616// WithContextCancel allows to call closer CloseAll on context cancel implicitly.
1717func WithContextCancel () Option {
18- return func (o * options ) {
18+ return func (o options ) options {
1919 o .ctxCancel = true
20+ return o
2021 }
2122}
2223
2324// WithSignals will trigger creation of signal notifiable context.
2425// The closer CloseAll will be called implicitly when any of the specified signals arrives.
2526func WithSignals (signals ... os.Signal ) Option {
26- return func (o * options ) {
27+ return func (o options ) options {
2728 o .ctxCancel = true
28- if o .signals == nil {
29- o .signals = signals
30- return
31- }
3229 o .signals = append (o .signals , signals ... )
30+ return o
3331 }
3432}
You can’t perform that action at this time.
0 commit comments