github.com/yaegashi/msgraph.go@v0.1.4/val/types.go (about)

     1  package val
     2  
     3  // Bool returns a bool value of p or false when p is nil
     4  func Bool(p *bool) bool {
     5  	if p != nil {
     6  		return *p
     7  	}
     8  	return false
     9  }
    10  
    11  // Int returns an int value of p or 0 when p is nil
    12  func Int(p *int) int {
    13  	if p != nil {
    14  		return *p
    15  	}
    16  	return 0
    17  }
    18  
    19  // Int8 returns an int8 value of p or 0 when p is nil
    20  func Int8(p *int8) int8 {
    21  	if p != nil {
    22  		return *p
    23  	}
    24  	return 0
    25  }
    26  
    27  // Int16 returns an int16 value of p or 0 when p is nil
    28  func Int16(p *int16) int16 {
    29  	if p != nil {
    30  		return *p
    31  	}
    32  	return 0
    33  }
    34  
    35  // Int32 returns an int32 value of p or 0 when p is nil
    36  func Int32(p *int32) int32 {
    37  	if p != nil {
    38  		return *p
    39  	}
    40  	return 0
    41  }
    42  
    43  // Int64 returns an int64 value of p or 0 when p is nil
    44  func Int64(p *int64) int64 {
    45  	if p != nil {
    46  		return *p
    47  	}
    48  	return 0
    49  }
    50  
    51  // Uint returns an uint value of p or 0 when p is nil
    52  func Uint(p *uint) uint {
    53  	if p != nil {
    54  		return *p
    55  	}
    56  	return 0
    57  }
    58  
    59  // Uint8 returns an uint8 value of p or 0 when p is nil
    60  func Uint8(p *uint8) uint8 {
    61  	if p != nil {
    62  		return *p
    63  	}
    64  	return 0
    65  }
    66  
    67  // Uint16 returns an uint16 value of p or 0 when p is nil
    68  func Uint16(p *uint16) uint16 {
    69  	if p != nil {
    70  		return *p
    71  	}
    72  	return 0
    73  }
    74  
    75  // Uint32 returns an uint32 value of p or 0 when p is nil
    76  func Uint32(p *uint32) uint32 {
    77  	if p != nil {
    78  		return *p
    79  	}
    80  	return 0
    81  }
    82  
    83  // Uint64 returns an uint64 value of p or 0 when p is nil
    84  func Uint64(p *uint64) uint64 {
    85  	if p != nil {
    86  		return *p
    87  	}
    88  	return 0
    89  }
    90  
    91  // Float32 returns a float32 value of p or 0 when p is nil
    92  func Float32(p *float32) float32 {
    93  	if p != nil {
    94  		return *p
    95  	}
    96  	return 0
    97  }
    98  
    99  // Float64 returns a float64 value of p or 0 when p is nil
   100  func Float64(p *float64) float64 {
   101  	if p != nil {
   102  		return *p
   103  	}
   104  	return 0
   105  }
   106  
   107  // String returns a string value of p or "" when p is nil
   108  func String(p *string) string {
   109  	if p != nil {
   110  		return *p
   111  	}
   112  	return ""
   113  }