...

Source file src/github.com/ory/x/pointerx/pointerx.go

Documentation: github.com/ory/x/pointerx

     1  package pointerx
     2  
     3  // String returns the input value's pointer.
     4  func String(s string) *string {
     5  	return &s
     6  }
     7  
     8  // StringR is the reverse to String.
     9  func StringR(s *string) string {
    10  	if s == nil {
    11  		return ""
    12  	}
    13  	return *s
    14  }
    15  
    16  // Int returns the input value's pointer.
    17  func Int(s int) *int {
    18  	return &s
    19  }
    20  
    21  // IntR is the reverse to Int.
    22  func IntR(s *int) int {
    23  	if s == nil {
    24  		return int(0)
    25  	}
    26  	return *s
    27  }
    28  
    29  // Int32 returns the input value's pointer.
    30  func Int32(s int32) *int32 {
    31  	return &s
    32  }
    33  
    34  // Int32R is the reverse to Int32.
    35  func Int32R(s *int32) int32 {
    36  	if s == nil {
    37  		return int32(0)
    38  	}
    39  	return *s
    40  }
    41  
    42  // Int64 returns the input value's pointer.
    43  func Int64(s int64) *int64 {
    44  	return &s
    45  }
    46  
    47  // Int64R is the reverse to Int64.
    48  func Int64R(s *int64) int64 {
    49  	if s == nil {
    50  		return int64(0)
    51  	}
    52  	return *s
    53  }
    54  
    55  // Float32 returns the input value's pointer.
    56  func Float32(s float32) *float32 {
    57  	return &s
    58  }
    59  
    60  // Float32R is the reverse to Float32.
    61  func Float32R(s *float32) float32 {
    62  	if s == nil {
    63  		return float32(0)
    64  	}
    65  	return *s
    66  }
    67  
    68  // Float64 returns the input value's pointer.
    69  func Float64(s float64) *float64 {
    70  	return &s
    71  }
    72  
    73  // Float64R is the reverse to Float64.
    74  func Float64R(s *float64) float64 {
    75  	if s == nil {
    76  		return float64(0)
    77  	}
    78  	return *s
    79  }
    80  
    81  // Bool returns the input value's pointer.
    82  func Bool(s bool) *bool {
    83  	return &s
    84  }
    85  
    86  // BoolR is the reverse to Bool.
    87  func BoolR(s *bool) bool {
    88  	if s == nil {
    89  		return false
    90  	}
    91  	return *s
    92  }
    93  

View as plain text