From a711da6b46581ff9b0f5c0dcb5d5910baf9d5bb3 Mon Sep 17 00:00:00 2001 From: kozyrev-m Date: Tue, 16 Apr 2024 20:15:28 +0500 Subject: [PATCH] add explicit initialization of fields of structures in internal/xsync --- internal/xsync/once.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/xsync/once.go b/internal/xsync/once.go index 35f5ed0aa..76431c460 100644 --- a/internal/xsync/once.go +++ b/internal/xsync/once.go @@ -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) {