Skip to content

Commit

Permalink
add explicit initialization of fields of structures in internal/xsync
Browse files Browse the repository at this point in the history
  • Loading branch information
kozyrev-m committed Apr 16, 2024
1 parent a1b0e00 commit a711da6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/xsync/once.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type Once[T closer.Closer] struct {
}

func OnceValue[T closer.Closer](f func() T) *Once[T] {
return &Once[T]{f: f}
return &Once[T]{f: f, t: f(), once: sync.Once{}, mutex: sync.RWMutex{}}
}

func (v *Once[T]) Close(ctx context.Context) (err error) {
Expand Down

0 comments on commit a711da6

Please sign in to comment.