chore: upgrade dependencies

This commit is contained in:
2022-06-09 12:30:53 +02:00
parent 7203f3d6a1
commit dcb93ec8f7
518 changed files with 27809 additions and 3222 deletions

View File

@@ -564,3 +564,38 @@ func ToTimeMap(vs map[string]*time.Time) map[string]time.Time {
return ps
}
// ToDuration returns time.Duration value dereferenced if the passed
// in pointer was not nil. Returns a time.Duration zero value if the
// pointer was nil.
func ToDuration(p *time.Duration) (v time.Duration) {
if p == nil {
return v
}
return *p
}
// ToDurationSlice returns a slice of time.Duration values, that are
// dereferenced if the passed in pointer was not nil. Returns a time.Duration
// zero value if the pointer was nil.
func ToDurationSlice(vs []*time.Duration) []time.Duration {
ps := make([]time.Duration, len(vs))
for i, v := range vs {
ps[i] = ToDuration(v)
}
return ps
}
// ToDurationMap returns a map of time.Duration values, that are
// dereferenced if the passed in pointer was not nil. The time.Duration
// zero value is used if the pointer was nil.
func ToDurationMap(vs map[string]*time.Duration) map[string]time.Duration {
ps := make(map[string]time.Duration, len(vs))
for k, v := range vs {
ps[k] = ToDuration(v)
}
return ps
}

View File

@@ -23,6 +23,7 @@ func GetScalars() Scalars {
{Type: "float32"},
{Type: "float64"},
{Type: "Time", Import: &Import{Path: "time"}},
{Type: "Duration", Import: &Import{Path: "time"}},
}
}

View File

@@ -468,3 +468,32 @@ func TimeMap(vs map[string]time.Time) map[string]*time.Time {
return ps
}
// Duration returns a pointer value for the time.Duration value passed in.
func Duration(v time.Duration) *time.Duration {
return &v
}
// DurationSlice returns a slice of time.Duration pointers from the values
// passed in.
func DurationSlice(vs []time.Duration) []*time.Duration {
ps := make([]*time.Duration, len(vs))
for i, v := range vs {
vv := v
ps[i] = &vv
}
return ps
}
// DurationMap returns a map of time.Duration pointers from the values
// passed in.
func DurationMap(vs map[string]time.Duration) map[string]*time.Duration {
ps := make(map[string]*time.Duration, len(vs))
for k, v := range vs {
vv := v
ps[k] = &vv
}
return ps
}