git.sr.ht/~pingoo/stdx@v0.0.0-20240218134121-094174641f6e/opt/opt.go (about)

     1  // package opt provides optional types. It can be useful for optional configuration paramteters
     2  package opt
     3  
     4  import "time"
     5  
     6  func String(str string) *string {
     7  	return &str
     8  }
     9  
    10  func Int(i int) *int {
    11  	return &i
    12  }
    13  
    14  func Int8(i int8) *int8 {
    15  	return &i
    16  }
    17  
    18  func Int16(i int16) *int16 {
    19  	return &i
    20  }
    21  
    22  func Int32(i int32) *int32 {
    23  	return &i
    24  }
    25  
    26  func Int64(i int64) *int64 {
    27  	return &i
    28  }
    29  
    30  func Uint(i uint) *uint {
    31  	return &i
    32  }
    33  
    34  func Uint8(i uint8) *uint8 {
    35  	return &i
    36  }
    37  
    38  func Uint16(i uint16) *uint16 {
    39  	return &i
    40  }
    41  
    42  func Uint32(i uint32) *uint32 {
    43  	return &i
    44  }
    45  
    46  func Uint64(i uint64) *uint64 {
    47  	return &i
    48  }
    49  
    50  func Time(t time.Time) *time.Time {
    51  	return &t
    52  }
    53  
    54  func Bool(v bool) *bool {
    55  	return &v
    56  }