From d3b9b85c2baa6b6d168204d9d7b4a563b2b61086 Mon Sep 17 00:00:00 2001 From: qmuntal Date: Fri, 27 Sep 2024 09:28:59 +0200 Subject: [PATCH] use oneliner to instantiate generic zero variables --- cng/cng.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cng/cng.go b/cng/cng.go index 29255e7..d1916f9 100644 --- a/cng/cng.go +++ b/cng/cng.go @@ -52,14 +52,12 @@ func loadOrStoreAlg[T any](id string, flags bcrypt.AlgorithmProviderFlags, mode var h bcrypt.ALG_HANDLE err := bcrypt.OpenAlgorithmProvider(&h, utf16PtrFromString(id), nil, flags) if err != nil { - var t T - return t, err + return *new(T), err } v, err := fn(h) if err != nil { bcrypt.CloseAlgorithmProvider(h, 0) - var t T - return t, err + return *new(T), err } if existing, loaded := algCache.LoadOrStore(entryKey, v); loaded { // We can safely use a provider that has already been cached in another concurrent goroutine.