github.com/aavshr/aws-sdk-go@v1.41.3/aws/convert_types.go (about)

     1  package aws
     2  
     3  import "time"
     4  
     5  // String returns a pointer to the string value passed in.
     6  func String(v string) *string {
     7  	return &v
     8  }
     9  
    10  // StringValue returns the value of the string pointer passed in or
    11  // "" if the pointer is nil.
    12  func StringValue(v *string) string {
    13  	if v != nil {
    14  		return *v
    15  	}
    16  	return ""
    17  }
    18  
    19  // StringSlice converts a slice of string values into a slice of
    20  // string pointers
    21  func StringSlice(src []string) []*string {
    22  	dst := make([]*string, len(src))
    23  	for i := 0; i < len(src); i++ {
    24  		dst[i] = &(src[i])
    25  	}
    26  	return dst
    27  }
    28  
    29  // StringValueSlice converts a slice of string pointers into a slice of
    30  // string values
    31  func StringValueSlice(src []*string) []string {
    32  	dst := make([]string, len(src))
    33  	for i := 0; i < len(src); i++ {
    34  		if src[i] != nil {
    35  			dst[i] = *(src[i])
    36  		}
    37  	}
    38  	return dst
    39  }
    40  
    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 {
    46  		v := val
    47  		dst[k] = &v
    48  	}
    49  	return dst
    50  }
    51  
    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 {
    57  		if val != nil {
    58  			dst[k] = *val
    59  		}
    60  	}
    61  	return dst
    62  }
    63  
    64  // Bool returns a pointer to the bool value passed in.
    65  func Bool(v bool) *bool {
    66  	return &v
    67  }
    68  
    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 {
    72  	if v != nil {
    73  		return *v
    74  	}
    75  	return false
    76  }
    77  
    78  // BoolSlice converts a slice of bool values into a slice of
    79  // bool pointers
    80  func BoolSlice(src []bool) []*bool {
    81  	dst := make([]*bool, len(src))
    82  	for i := 0; i < len(src); i++ {
    83  		dst[i] = &(src[i])
    84  	}
    85  	return dst
    86  }
    87  
    88  // BoolValueSlice converts a slice of bool pointers into a slice of
    89  // bool values
    90  func BoolValueSlice(src []*bool) []bool {
    91  	dst := make([]bool, len(src))
    92  	for i := 0; i < len(src); i++ {
    93  		if src[i] != nil {
    94  			dst[i] = *(src[i])
    95  		}
    96  	}
    97  	return dst
    98  }
    99  
   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 {
   105  		v := val
   106  		dst[k] = &v
   107  	}
   108  	return dst
   109  }
   110  
   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 {
   116  		if val != nil {
   117  			dst[k] = *val
   118  		}
   119  	}
   120  	return dst
   121  }
   122  
   123  // Int returns a pointer to the int value passed in.
   124  func Int(v int) *int {
   125  	return &v
   126  }
   127  
   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 {
   131  	if v != nil {
   132  		return *v
   133  	}
   134  	return 0
   135  }
   136  
   137  // IntSlice converts a slice of int values into a slice of
   138  // int pointers
   139  func IntSlice(src []int) []*int {
   140  	dst := make([]*int, len(src))
   141  	for i := 0; i < len(src); i++ {
   142  		dst[i] = &(src[i])
   143  	}
   144  	return dst
   145  }
   146  
   147  // IntValueSlice converts a slice of int pointers into a slice of
   148  // int values
   149  func IntValueSlice(src []*int) []int {
   150  	dst := make([]int, len(src))
   151  	for i := 0; i < len(src); i++ {
   152  		if src[i] != nil {
   153  			dst[i] = *(src[i])
   154  		}
   155  	}
   156  	return dst
   157  }
   158  
   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 {
   164  		v := val
   165  		dst[k] = &v
   166  	}
   167  	return dst
   168  }
   169  
   170  // IntValueMap converts a string map of int pointers into a string
   171  // map of int values
   172  func IntValueMap(src map[string]*int) map[string]int {
   173  	dst := make(map[string]int)
   174  	for k, val := range src {
   175  		if val != nil {
   176  			dst[k] = *val
   177  		}
   178  	}
   179  	return dst
   180  }
   181  
   182  // Uint returns a pointer to the uint value passed in.
   183  func Uint(v uint) *uint {
   184  	return &v
   185  }
   186  
   187  // UintValue returns the value of the uint pointer passed in or
   188  // 0 if the pointer is nil.
   189  func UintValue(v *uint) uint {
   190  	if v != nil {
   191  		return *v
   192  	}
   193  	return 0
   194  }
   195  
   196  // UintSlice converts a slice of uint values uinto a slice of
   197  // uint pointers
   198  func UintSlice(src []uint) []*uint {
   199  	dst := make([]*uint, len(src))
   200  	for i := 0; i < len(src); i++ {
   201  		dst[i] = &(src[i])
   202  	}
   203  	return dst
   204  }
   205  
   206  // UintValueSlice converts a slice of uint pointers uinto a slice of
   207  // uint values
   208  func UintValueSlice(src []*uint) []uint {
   209  	dst := make([]uint, len(src))
   210  	for i := 0; i < len(src); i++ {
   211  		if src[i] != nil {
   212  			dst[i] = *(src[i])
   213  		}
   214  	}
   215  	return dst
   216  }
   217  
   218  // UintMap converts a string map of uint values uinto a string
   219  // map of uint pointers
   220  func UintMap(src map[string]uint) map[string]*uint {
   221  	dst := make(map[string]*uint)
   222  	for k, val := range src {
   223  		v := val
   224  		dst[k] = &v
   225  	}
   226  	return dst
   227  }
   228  
   229  // UintValueMap converts a string map of uint pointers uinto a string
   230  // map of uint values
   231  func UintValueMap(src map[string]*uint) map[string]uint {
   232  	dst := make(map[string]uint)
   233  	for k, val := range src {
   234  		if val != nil {
   235  			dst[k] = *val
   236  		}
   237  	}
   238  	return dst
   239  }
   240  
   241  // Int8 returns a pointer to the int8 value passed in.
   242  func Int8(v int8) *int8 {
   243  	return &v
   244  }
   245  
   246  // Int8Value returns the value of the int8 pointer passed in or
   247  // 0 if the pointer is nil.
   248  func Int8Value(v *int8) int8 {
   249  	if v != nil {
   250  		return *v
   251  	}
   252  	return 0
   253  }
   254  
   255  // Int8Slice converts a slice of int8 values into a slice of
   256  // int8 pointers
   257  func Int8Slice(src []int8) []*int8 {
   258  	dst := make([]*int8, len(src))
   259  	for i := 0; i < len(src); i++ {
   260  		dst[i] = &(src[i])
   261  	}
   262  	return dst
   263  }
   264  
   265  // Int8ValueSlice converts a slice of int8 pointers into a slice of
   266  // int8 values
   267  func Int8ValueSlice(src []*int8) []int8 {
   268  	dst := make([]int8, len(src))
   269  	for i := 0; i < len(src); i++ {
   270  		if src[i] != nil {
   271  			dst[i] = *(src[i])
   272  		}
   273  	}
   274  	return dst
   275  }
   276  
   277  // Int8Map converts a string map of int8 values into a string
   278  // map of int8 pointers
   279  func Int8Map(src map[string]int8) map[string]*int8 {
   280  	dst := make(map[string]*int8)
   281  	for k, val := range src {
   282  		v := val
   283  		dst[k] = &v
   284  	}
   285  	return dst
   286  }
   287  
   288  // Int8ValueMap converts a string map of int8 pointers into a string
   289  // map of int8 values
   290  func Int8ValueMap(src map[string]*int8) map[string]int8 {
   291  	dst := make(map[string]int8)
   292  	for k, val := range src {
   293  		if val != nil {
   294  			dst[k] = *val
   295  		}
   296  	}
   297  	return dst
   298  }
   299  
   300  // Int16 returns a pointer to the int16 value passed in.
   301  func Int16(v int16) *int16 {
   302  	return &v
   303  }
   304  
   305  // Int16Value returns the value of the int16 pointer passed in or
   306  // 0 if the pointer is nil.
   307  func Int16Value(v *int16) int16 {
   308  	if v != nil {
   309  		return *v
   310  	}
   311  	return 0
   312  }
   313  
   314  // Int16Slice converts a slice of int16 values into a slice of
   315  // int16 pointers
   316  func Int16Slice(src []int16) []*int16 {
   317  	dst := make([]*int16, len(src))
   318  	for i := 0; i < len(src); i++ {
   319  		dst[i] = &(src[i])
   320  	}
   321  	return dst
   322  }
   323  
   324  // Int16ValueSlice converts a slice of int16 pointers into a slice of
   325  // int16 values
   326  func Int16ValueSlice(src []*int16) []int16 {
   327  	dst := make([]int16, len(src))
   328  	for i := 0; i < len(src); i++ {
   329  		if src[i] != nil {
   330  			dst[i] = *(src[i])
   331  		}
   332  	}
   333  	return dst
   334  }
   335  
   336  // Int16Map converts a string map of int16 values into a string
   337  // map of int16 pointers
   338  func Int16Map(src map[string]int16) map[string]*int16 {
   339  	dst := make(map[string]*int16)
   340  	for k, val := range src {
   341  		v := val
   342  		dst[k] = &v
   343  	}
   344  	return dst
   345  }
   346  
   347  // Int16ValueMap converts a string map of int16 pointers into a string
   348  // map of int16 values
   349  func Int16ValueMap(src map[string]*int16) map[string]int16 {
   350  	dst := make(map[string]int16)
   351  	for k, val := range src {
   352  		if val != nil {
   353  			dst[k] = *val
   354  		}
   355  	}
   356  	return dst
   357  }
   358  
   359  // Int32 returns a pointer to the int32 value passed in.
   360  func Int32(v int32) *int32 {
   361  	return &v
   362  }
   363  
   364  // Int32Value returns the value of the int32 pointer passed in or
   365  // 0 if the pointer is nil.
   366  func Int32Value(v *int32) int32 {
   367  	if v != nil {
   368  		return *v
   369  	}
   370  	return 0
   371  }
   372  
   373  // Int32Slice converts a slice of int32 values into a slice of
   374  // int32 pointers
   375  func Int32Slice(src []int32) []*int32 {
   376  	dst := make([]*int32, len(src))
   377  	for i := 0; i < len(src); i++ {
   378  		dst[i] = &(src[i])
   379  	}
   380  	return dst
   381  }
   382  
   383  // Int32ValueSlice converts a slice of int32 pointers into a slice of
   384  // int32 values
   385  func Int32ValueSlice(src []*int32) []int32 {
   386  	dst := make([]int32, len(src))
   387  	for i := 0; i < len(src); i++ {
   388  		if src[i] != nil {
   389  			dst[i] = *(src[i])
   390  		}
   391  	}
   392  	return dst
   393  }
   394  
   395  // Int32Map converts a string map of int32 values into a string
   396  // map of int32 pointers
   397  func Int32Map(src map[string]int32) map[string]*int32 {
   398  	dst := make(map[string]*int32)
   399  	for k, val := range src {
   400  		v := val
   401  		dst[k] = &v
   402  	}
   403  	return dst
   404  }
   405  
   406  // Int32ValueMap converts a string map of int32 pointers into a string
   407  // map of int32 values
   408  func Int32ValueMap(src map[string]*int32) map[string]int32 {
   409  	dst := make(map[string]int32)
   410  	for k, val := range src {
   411  		if val != nil {
   412  			dst[k] = *val
   413  		}
   414  	}
   415  	return dst
   416  }
   417  
   418  // Int64 returns a pointer to the int64 value passed in.
   419  func Int64(v int64) *int64 {
   420  	return &v
   421  }
   422  
   423  // Int64Value returns the value of the int64 pointer passed in or
   424  // 0 if the pointer is nil.
   425  func Int64Value(v *int64) int64 {
   426  	if v != nil {
   427  		return *v
   428  	}
   429  	return 0
   430  }
   431  
   432  // Int64Slice converts a slice of int64 values into a slice of
   433  // int64 pointers
   434  func Int64Slice(src []int64) []*int64 {
   435  	dst := make([]*int64, len(src))
   436  	for i := 0; i < len(src); i++ {
   437  		dst[i] = &(src[i])
   438  	}
   439  	return dst
   440  }
   441  
   442  // Int64ValueSlice converts a slice of int64 pointers into a slice of
   443  // int64 values
   444  func Int64ValueSlice(src []*int64) []int64 {
   445  	dst := make([]int64, len(src))
   446  	for i := 0; i < len(src); i++ {
   447  		if src[i] != nil {
   448  			dst[i] = *(src[i])
   449  		}
   450  	}
   451  	return dst
   452  }
   453  
   454  // Int64Map converts a string map of int64 values into a string
   455  // map of int64 pointers
   456  func Int64Map(src map[string]int64) map[string]*int64 {
   457  	dst := make(map[string]*int64)
   458  	for k, val := range src {
   459  		v := val
   460  		dst[k] = &v
   461  	}
   462  	return dst
   463  }
   464  
   465  // Int64ValueMap converts a string map of int64 pointers into a string
   466  // map of int64 values
   467  func Int64ValueMap(src map[string]*int64) map[string]int64 {
   468  	dst := make(map[string]int64)
   469  	for k, val := range src {
   470  		if val != nil {
   471  			dst[k] = *val
   472  		}
   473  	}
   474  	return dst
   475  }
   476  
   477  // Uint8 returns a pointer to the uint8 value passed in.
   478  func Uint8(v uint8) *uint8 {
   479  	return &v
   480  }
   481  
   482  // Uint8Value returns the value of the uint8 pointer passed in or
   483  // 0 if the pointer is nil.
   484  func Uint8Value(v *uint8) uint8 {
   485  	if v != nil {
   486  		return *v
   487  	}
   488  	return 0
   489  }
   490  
   491  // Uint8Slice converts a slice of uint8 values into a slice of
   492  // uint8 pointers
   493  func Uint8Slice(src []uint8) []*uint8 {
   494  	dst := make([]*uint8, len(src))
   495  	for i := 0; i < len(src); i++ {
   496  		dst[i] = &(src[i])
   497  	}
   498  	return dst
   499  }
   500  
   501  // Uint8ValueSlice converts a slice of uint8 pointers into a slice of
   502  // uint8 values
   503  func Uint8ValueSlice(src []*uint8) []uint8 {
   504  	dst := make([]uint8, len(src))
   505  	for i := 0; i < len(src); i++ {
   506  		if src[i] != nil {
   507  			dst[i] = *(src[i])
   508  		}
   509  	}
   510  	return dst
   511  }
   512  
   513  // Uint8Map converts a string map of uint8 values into a string
   514  // map of uint8 pointers
   515  func Uint8Map(src map[string]uint8) map[string]*uint8 {
   516  	dst := make(map[string]*uint8)
   517  	for k, val := range src {
   518  		v := val
   519  		dst[k] = &v
   520  	}
   521  	return dst
   522  }
   523  
   524  // Uint8ValueMap converts a string map of uint8 pointers into a string
   525  // map of uint8 values
   526  func Uint8ValueMap(src map[string]*uint8) map[string]uint8 {
   527  	dst := make(map[string]uint8)
   528  	for k, val := range src {
   529  		if val != nil {
   530  			dst[k] = *val
   531  		}
   532  	}
   533  	return dst
   534  }
   535  
   536  // Uint16 returns a pointer to the uint16 value passed in.
   537  func Uint16(v uint16) *uint16 {
   538  	return &v
   539  }
   540  
   541  // Uint16Value returns the value of the uint16 pointer passed in or
   542  // 0 if the pointer is nil.
   543  func Uint16Value(v *uint16) uint16 {
   544  	if v != nil {
   545  		return *v
   546  	}
   547  	return 0
   548  }
   549  
   550  // Uint16Slice converts a slice of uint16 values into a slice of
   551  // uint16 pointers
   552  func Uint16Slice(src []uint16) []*uint16 {
   553  	dst := make([]*uint16, len(src))
   554  	for i := 0; i < len(src); i++ {
   555  		dst[i] = &(src[i])
   556  	}
   557  	return dst
   558  }
   559  
   560  // Uint16ValueSlice converts a slice of uint16 pointers into a slice of
   561  // uint16 values
   562  func Uint16ValueSlice(src []*uint16) []uint16 {
   563  	dst := make([]uint16, len(src))
   564  	for i := 0; i < len(src); i++ {
   565  		if src[i] != nil {
   566  			dst[i] = *(src[i])
   567  		}
   568  	}
   569  	return dst
   570  }
   571  
   572  // Uint16Map converts a string map of uint16 values into a string
   573  // map of uint16 pointers
   574  func Uint16Map(src map[string]uint16) map[string]*uint16 {
   575  	dst := make(map[string]*uint16)
   576  	for k, val := range src {
   577  		v := val
   578  		dst[k] = &v
   579  	}
   580  	return dst
   581  }
   582  
   583  // Uint16ValueMap converts a string map of uint16 pointers into a string
   584  // map of uint16 values
   585  func Uint16ValueMap(src map[string]*uint16) map[string]uint16 {
   586  	dst := make(map[string]uint16)
   587  	for k, val := range src {
   588  		if val != nil {
   589  			dst[k] = *val
   590  		}
   591  	}
   592  	return dst
   593  }
   594  
   595  // Uint32 returns a pointer to the uint32 value passed in.
   596  func Uint32(v uint32) *uint32 {
   597  	return &v
   598  }
   599  
   600  // Uint32Value returns the value of the uint32 pointer passed in or
   601  // 0 if the pointer is nil.
   602  func Uint32Value(v *uint32) uint32 {
   603  	if v != nil {
   604  		return *v
   605  	}
   606  	return 0
   607  }
   608  
   609  // Uint32Slice converts a slice of uint32 values into a slice of
   610  // uint32 pointers
   611  func Uint32Slice(src []uint32) []*uint32 {
   612  	dst := make([]*uint32, len(src))
   613  	for i := 0; i < len(src); i++ {
   614  		dst[i] = &(src[i])
   615  	}
   616  	return dst
   617  }
   618  
   619  // Uint32ValueSlice converts a slice of uint32 pointers into a slice of
   620  // uint32 values
   621  func Uint32ValueSlice(src []*uint32) []uint32 {
   622  	dst := make([]uint32, len(src))
   623  	for i := 0; i < len(src); i++ {
   624  		if src[i] != nil {
   625  			dst[i] = *(src[i])
   626  		}
   627  	}
   628  	return dst
   629  }
   630  
   631  // Uint32Map converts a string map of uint32 values into a string
   632  // map of uint32 pointers
   633  func Uint32Map(src map[string]uint32) map[string]*uint32 {
   634  	dst := make(map[string]*uint32)
   635  	for k, val := range src {
   636  		v := val
   637  		dst[k] = &v
   638  	}
   639  	return dst
   640  }
   641  
   642  // Uint32ValueMap converts a string map of uint32 pointers into a string
   643  // map of uint32 values
   644  func Uint32ValueMap(src map[string]*uint32) map[string]uint32 {
   645  	dst := make(map[string]uint32)
   646  	for k, val := range src {
   647  		if val != nil {
   648  			dst[k] = *val
   649  		}
   650  	}
   651  	return dst
   652  }
   653  
   654  // Uint64 returns a pointer to the uint64 value passed in.
   655  func Uint64(v uint64) *uint64 {
   656  	return &v
   657  }
   658  
   659  // Uint64Value returns the value of the uint64 pointer passed in or
   660  // 0 if the pointer is nil.
   661  func Uint64Value(v *uint64) uint64 {
   662  	if v != nil {
   663  		return *v
   664  	}
   665  	return 0
   666  }
   667  
   668  // Uint64Slice converts a slice of uint64 values into a slice of
   669  // uint64 pointers
   670  func Uint64Slice(src []uint64) []*uint64 {
   671  	dst := make([]*uint64, len(src))
   672  	for i := 0; i < len(src); i++ {
   673  		dst[i] = &(src[i])
   674  	}
   675  	return dst
   676  }
   677  
   678  // Uint64ValueSlice converts a slice of uint64 pointers into a slice of
   679  // uint64 values
   680  func Uint64ValueSlice(src []*uint64) []uint64 {
   681  	dst := make([]uint64, len(src))
   682  	for i := 0; i < len(src); i++ {
   683  		if src[i] != nil {
   684  			dst[i] = *(src[i])
   685  		}
   686  	}
   687  	return dst
   688  }
   689  
   690  // Uint64Map converts a string map of uint64 values into a string
   691  // map of uint64 pointers
   692  func Uint64Map(src map[string]uint64) map[string]*uint64 {
   693  	dst := make(map[string]*uint64)
   694  	for k, val := range src {
   695  		v := val
   696  		dst[k] = &v
   697  	}
   698  	return dst
   699  }
   700  
   701  // Uint64ValueMap converts a string map of uint64 pointers into a string
   702  // map of uint64 values
   703  func Uint64ValueMap(src map[string]*uint64) map[string]uint64 {
   704  	dst := make(map[string]uint64)
   705  	for k, val := range src {
   706  		if val != nil {
   707  			dst[k] = *val
   708  		}
   709  	}
   710  	return dst
   711  }
   712  
   713  // Float32 returns a pointer to the float32 value passed in.
   714  func Float32(v float32) *float32 {
   715  	return &v
   716  }
   717  
   718  // Float32Value returns the value of the float32 pointer passed in or
   719  // 0 if the pointer is nil.
   720  func Float32Value(v *float32) float32 {
   721  	if v != nil {
   722  		return *v
   723  	}
   724  	return 0
   725  }
   726  
   727  // Float32Slice converts a slice of float32 values into a slice of
   728  // float32 pointers
   729  func Float32Slice(src []float32) []*float32 {
   730  	dst := make([]*float32, len(src))
   731  	for i := 0; i < len(src); i++ {
   732  		dst[i] = &(src[i])
   733  	}
   734  	return dst
   735  }
   736  
   737  // Float32ValueSlice converts a slice of float32 pointers into a slice of
   738  // float32 values
   739  func Float32ValueSlice(src []*float32) []float32 {
   740  	dst := make([]float32, len(src))
   741  	for i := 0; i < len(src); i++ {
   742  		if src[i] != nil {
   743  			dst[i] = *(src[i])
   744  		}
   745  	}
   746  	return dst
   747  }
   748  
   749  // Float32Map converts a string map of float32 values into a string
   750  // map of float32 pointers
   751  func Float32Map(src map[string]float32) map[string]*float32 {
   752  	dst := make(map[string]*float32)
   753  	for k, val := range src {
   754  		v := val
   755  		dst[k] = &v
   756  	}
   757  	return dst
   758  }
   759  
   760  // Float32ValueMap converts a string map of float32 pointers into a string
   761  // map of float32 values
   762  func Float32ValueMap(src map[string]*float32) map[string]float32 {
   763  	dst := make(map[string]float32)
   764  	for k, val := range src {
   765  		if val != nil {
   766  			dst[k] = *val
   767  		}
   768  	}
   769  	return dst
   770  }
   771  
   772  // Float64 returns a pointer to the float64 value passed in.
   773  func Float64(v float64) *float64 {
   774  	return &v
   775  }
   776  
   777  // Float64Value returns the value of the float64 pointer passed in or
   778  // 0 if the pointer is nil.
   779  func Float64Value(v *float64) float64 {
   780  	if v != nil {
   781  		return *v
   782  	}
   783  	return 0
   784  }
   785  
   786  // Float64Slice converts a slice of float64 values into a slice of
   787  // float64 pointers
   788  func Float64Slice(src []float64) []*float64 {
   789  	dst := make([]*float64, len(src))
   790  	for i := 0; i < len(src); i++ {
   791  		dst[i] = &(src[i])
   792  	}
   793  	return dst
   794  }
   795  
   796  // Float64ValueSlice converts a slice of float64 pointers into a slice of
   797  // float64 values
   798  func Float64ValueSlice(src []*float64) []float64 {
   799  	dst := make([]float64, len(src))
   800  	for i := 0; i < len(src); i++ {
   801  		if src[i] != nil {
   802  			dst[i] = *(src[i])
   803  		}
   804  	}
   805  	return dst
   806  }
   807  
   808  // Float64Map converts a string map of float64 values into a string
   809  // map of float64 pointers
   810  func Float64Map(src map[string]float64) map[string]*float64 {
   811  	dst := make(map[string]*float64)
   812  	for k, val := range src {
   813  		v := val
   814  		dst[k] = &v
   815  	}
   816  	return dst
   817  }
   818  
   819  // Float64ValueMap converts a string map of float64 pointers into a string
   820  // map of float64 values
   821  func Float64ValueMap(src map[string]*float64) map[string]float64 {
   822  	dst := make(map[string]float64)
   823  	for k, val := range src {
   824  		if val != nil {
   825  			dst[k] = *val
   826  		}
   827  	}
   828  	return dst
   829  }
   830  
   831  // Time returns a pointer to the time.Time value passed in.
   832  func Time(v time.Time) *time.Time {
   833  	return &v
   834  }
   835  
   836  // TimeValue returns the value of the time.Time pointer passed in or
   837  // time.Time{} if the pointer is nil.
   838  func TimeValue(v *time.Time) time.Time {
   839  	if v != nil {
   840  		return *v
   841  	}
   842  	return time.Time{}
   843  }
   844  
   845  // SecondsTimeValue converts an int64 pointer to a time.Time value
   846  // representing seconds since Epoch or time.Time{} if the pointer is nil.
   847  func SecondsTimeValue(v *int64) time.Time {
   848  	if v != nil {
   849  		return time.Unix((*v / 1000), 0)
   850  	}
   851  	return time.Time{}
   852  }
   853  
   854  // MillisecondsTimeValue converts an int64 pointer to a time.Time value
   855  // representing milliseconds sinch Epoch or time.Time{} if the pointer is nil.
   856  func MillisecondsTimeValue(v *int64) time.Time {
   857  	if v != nil {
   858  		return time.Unix(0, (*v * 1000000))
   859  	}
   860  	return time.Time{}
   861  }
   862  
   863  // TimeUnixMilli returns a Unix timestamp in milliseconds from "January 1, 1970 UTC".
   864  // The result is undefined if the Unix time cannot be represented by an int64.
   865  // Which includes calling TimeUnixMilli on a zero Time is undefined.
   866  //
   867  // This utility is useful for service API's such as CloudWatch Logs which require
   868  // their unix time values to be in milliseconds.
   869  //
   870  // See Go stdlib https://golang.org/pkg/time/#Time.UnixNano for more information.
   871  func TimeUnixMilli(t time.Time) int64 {
   872  	return t.UnixNano() / int64(time.Millisecond/time.Nanosecond)
   873  }
   874  
   875  // TimeSlice converts a slice of time.Time values into a slice of
   876  // time.Time pointers
   877  func TimeSlice(src []time.Time) []*time.Time {
   878  	dst := make([]*time.Time, len(src))
   879  	for i := 0; i < len(src); i++ {
   880  		dst[i] = &(src[i])
   881  	}
   882  	return dst
   883  }
   884  
   885  // TimeValueSlice converts a slice of time.Time pointers into a slice of
   886  // time.Time values
   887  func TimeValueSlice(src []*time.Time) []time.Time {
   888  	dst := make([]time.Time, len(src))
   889  	for i := 0; i < len(src); i++ {
   890  		if src[i] != nil {
   891  			dst[i] = *(src[i])
   892  		}
   893  	}
   894  	return dst
   895  }
   896  
   897  // TimeMap converts a string map of time.Time values into a string
   898  // map of time.Time pointers
   899  func TimeMap(src map[string]time.Time) map[string]*time.Time {
   900  	dst := make(map[string]*time.Time)
   901  	for k, val := range src {
   902  		v := val
   903  		dst[k] = &v
   904  	}
   905  	return dst
   906  }
   907  
   908  // TimeValueMap converts a string map of time.Time pointers into a string
   909  // map of time.Time values
   910  func TimeValueMap(src map[string]*time.Time) map[string]time.Time {
   911  	dst := make(map[string]time.Time)
   912  	for k, val := range src {
   913  		if val != nil {
   914  			dst[k] = *val
   915  		}
   916  	}
   917  	return dst
   918  }