5 // String returns a pointer to the string value passed in.
6 func String(v string) *string {
10 // StringValue returns the value of the string pointer passed in or
11 // "" if the pointer is nil.
12 func StringValue(v *string) string {
19 // StringSlice converts a slice of string values into a slice of
21 func StringSlice(src []string) []*string {
22 dst := make([]*string, len(src))
23 for i := 0; i < len(src); i++ {
29 // StringValueSlice converts a slice of string pointers into a slice of
31 func StringValueSlice(src []*string) []string {
32 dst := make([]string, len(src))
33 for i := 0; i < len(src); i++ {
41 // StringMap converts a string map of string values into a string
42 // map of string pointers
43 func StringMap(src map[string]string) map[string]*string {
44 dst := make(map[string]*string)
45 for k, val := range src {
52 // StringValueMap converts a string map of string pointers into a string
53 // map of string values
54 func StringValueMap(src map[string]*string) map[string]string {
55 dst := make(map[string]string)
56 for k, val := range src {
64 // Bool returns a pointer to the bool value passed in.
65 func Bool(v bool) *bool {
69 // BoolValue returns the value of the bool pointer passed in or
70 // false if the pointer is nil.
71 func BoolValue(v *bool) bool {
78 // BoolSlice converts a slice of bool values into a slice of
80 func BoolSlice(src []bool) []*bool {
81 dst := make([]*bool, len(src))
82 for i := 0; i < len(src); i++ {
88 // BoolValueSlice converts a slice of bool pointers into a slice of
90 func BoolValueSlice(src []*bool) []bool {
91 dst := make([]bool, len(src))
92 for i := 0; i < len(src); i++ {
100 // BoolMap converts a string map of bool values into a string
101 // map of bool pointers
102 func BoolMap(src map[string]bool) map[string]*bool {
103 dst := make(map[string]*bool)
104 for k, val := range src {
111 // BoolValueMap converts a string map of bool pointers into a string
112 // map of bool values
113 func BoolValueMap(src map[string]*bool) map[string]bool {
114 dst := make(map[string]bool)
115 for k, val := range src {
123 // Int returns a pointer to the int value passed in.
124 func Int(v int) *int {
128 // IntValue returns the value of the int pointer passed in or
129 // 0 if the pointer is nil.
130 func IntValue(v *int) int {
137 // IntSlice converts a slice of int values into a slice of
139 func IntSlice(src []int) []*int {
140 dst := make([]*int, len(src))
141 for i := 0; i < len(src); i++ {
147 // IntValueSlice converts a slice of int pointers into a slice of
149 func IntValueSlice(src []*int) []int {
150 dst := make([]int, len(src))
151 for i := 0; i < len(src); i++ {
159 // IntMap converts a string map of int values into a string
160 // map of int pointers
161 func IntMap(src map[string]int) map[string]*int {
162 dst := make(map[string]*int)
163 for k, val := range src {
170 // IntValueMap converts a string map of int pointers into a string
172 func IntValueMap(src map[string]*int) map[string]int {
173 dst := make(map[string]int)
174 for k, val := range src {
182 // Int64 returns a pointer to the int64 value passed in.
183 func Int64(v int64) *int64 {
187 // Int64Value returns the value of the int64 pointer passed in or
188 // 0 if the pointer is nil.
189 func Int64Value(v *int64) int64 {
196 // Int64Slice converts a slice of int64 values into a slice of
198 func Int64Slice(src []int64) []*int64 {
199 dst := make([]*int64, len(src))
200 for i := 0; i < len(src); i++ {
206 // Int64ValueSlice converts a slice of int64 pointers into a slice of
208 func Int64ValueSlice(src []*int64) []int64 {
209 dst := make([]int64, len(src))
210 for i := 0; i < len(src); i++ {
218 // Int64Map converts a string map of int64 values into a string
219 // map of int64 pointers
220 func Int64Map(src map[string]int64) map[string]*int64 {
221 dst := make(map[string]*int64)
222 for k, val := range src {
229 // Int64ValueMap converts a string map of int64 pointers into a string
230 // map of int64 values
231 func Int64ValueMap(src map[string]*int64) map[string]int64 {
232 dst := make(map[string]int64)
233 for k, val := range src {
241 // Float64 returns a pointer to the float64 value passed in.
242 func Float64(v float64) *float64 {
246 // Float64Value returns the value of the float64 pointer passed in or
247 // 0 if the pointer is nil.
248 func Float64Value(v *float64) float64 {
255 // Float64Slice converts a slice of float64 values into a slice of
257 func Float64Slice(src []float64) []*float64 {
258 dst := make([]*float64, len(src))
259 for i := 0; i < len(src); i++ {
265 // Float64ValueSlice converts a slice of float64 pointers into a slice of
267 func Float64ValueSlice(src []*float64) []float64 {
268 dst := make([]float64, len(src))
269 for i := 0; i < len(src); i++ {
277 // Float64Map converts a string map of float64 values into a string
278 // map of float64 pointers
279 func Float64Map(src map[string]float64) map[string]*float64 {
280 dst := make(map[string]*float64)
281 for k, val := range src {
288 // Float64ValueMap converts a string map of float64 pointers into a string
289 // map of float64 values
290 func Float64ValueMap(src map[string]*float64) map[string]float64 {
291 dst := make(map[string]float64)
292 for k, val := range src {
300 // Time returns a pointer to the time.Time value passed in.
301 func Time(v time.Time) *time.Time {
305 // TimeValue returns the value of the time.Time pointer passed in or
306 // time.Time{} if the pointer is nil.
307 func TimeValue(v *time.Time) time.Time {
314 // TimeUnixMilli returns a Unix timestamp in milliseconds from "January 1, 1970 UTC".
315 // The result is undefined if the Unix time cannot be represented by an int64.
316 // Which includes calling TimeUnixMilli on a zero Time is undefined.
318 // This utility is useful for service API's such as CloudWatch Logs which require
319 // their unix time values to be in milliseconds.
321 // See Go stdlib https://golang.org/pkg/time/#Time.UnixNano for more information.
322 func TimeUnixMilli(t time.Time) int64 {
323 return t.UnixNano() / int64(time.Millisecond/time.Nanosecond)
326 // TimeSlice converts a slice of time.Time values into a slice of
327 // time.Time pointers
328 func TimeSlice(src []time.Time) []*time.Time {
329 dst := make([]*time.Time, len(src))
330 for i := 0; i < len(src); i++ {
336 // TimeValueSlice converts a slice of time.Time pointers into a slice of
338 func TimeValueSlice(src []*time.Time) []time.Time {
339 dst := make([]time.Time, len(src))
340 for i := 0; i < len(src); i++ {
348 // TimeMap converts a string map of time.Time values into a string
349 // map of time.Time pointers
350 func TimeMap(src map[string]time.Time) map[string]*time.Time {
351 dst := make(map[string]*time.Time)
352 for k, val := range src {
359 // TimeValueMap converts a string map of time.Time pointers into a string
360 // map of time.Time values
361 func TimeValueMap(src map[string]*time.Time) map[string]time.Time {
362 dst := make(map[string]time.Time)
363 for k, val := range src {