Skip to content

Commit

Permalink
Update function description
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisoz committed Nov 13, 2023
1 parent 6ff03b5 commit 372781b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions safeptr.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ limitations under the License.

package klog

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

0 comments on commit 372781b

Please sign in to comment.