From 7026a5ddff12f66c560970db434f89395cdddd85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sun, 10 Dec 2023 21:47:32 +0800 Subject: [PATCH] Add `Ptr` function to common A new function Ptr has been added to common/cond.go. This function returns address of any type of object that is passed as an argument to it. This enhancement will be useful in many scenarios where pointer to an object is required. --- common/cond.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/cond.go b/common/cond.go index 81843dd9..a4c66a78 100644 --- a/common/cond.go +++ b/common/cond.go @@ -336,6 +336,10 @@ func DefaultValue[T any]() T { return defaultValue } +func Ptr[T any](obj T) *T { + return &obj +} + func Close(closers ...any) error { var retErr error for _, closer := range closers {