github.com/prebid/prebid-server/v2@v2.18.0/util/ptrutil/ptrutil.go (about)

     1  package ptrutil
     2  
     3  func ToPtr[T any](v T) *T {
     4  	return &v
     5  }
     6  
     7  func Clone[T any](v *T) *T {
     8  	if v == nil {
     9  		return nil
    10  	}
    11  
    12  	clone := *v
    13  	return &clone
    14  }
    15  
    16  func ValueOrDefault[T any](v *T) T {
    17  	if v != nil {
    18  		return *v
    19  	}
    20  
    21  	var def T
    22  	return def
    23  }