Skip to content

Commit 372781b

Browse files
committed
Update function description
1 parent 6ff03b5 commit 372781b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

safeptr.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ limitations under the License.
1919

2020
package klog
2121

22-
// SafePtr accepts a pointer of any type (T) as an argument and returns th
22+
// SafePtr accepts a pointer of any type (T) as an argument and returns the
2323
// same pointer if it's not nil, otherwise it returns nil.
24-
// This function is useful for safely handling pointers and preventing nil pointer dereferencing.
24+
// This function is useful for safely handling pointers and preventing nil pointer dereferencing when the type
25+
//
26+
// a) implements interfaces called by the logger like `fmt.Stringer` and b) those implementations do not check for nil themselves.
2527
func SafePtr[T any](p *T) any {
2628
if p == nil {
2729
return nil

0 commit comments

Comments
 (0)