From 7b320119ba532fd409ec7dade7ad02011c309599 Mon Sep 17 00:00:00 2001 From: Niall Sheridan Date: Wed, 18 Oct 2017 13:15:14 +0100 Subject: Update dependencies --- vendor/cloud.google.com/go/internal/optional/optional.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'vendor/cloud.google.com/go/internal/optional') diff --git a/vendor/cloud.google.com/go/internal/optional/optional.go b/vendor/cloud.google.com/go/internal/optional/optional.go index f9102f3..4c15410 100644 --- a/vendor/cloud.google.com/go/internal/optional/optional.go +++ b/vendor/cloud.google.com/go/internal/optional/optional.go @@ -20,6 +20,7 @@ package optional import ( "fmt" "strings" + "time" ) type ( @@ -37,6 +38,9 @@ type ( // Float64 is either a float64 or nil. Float64 interface{} + + // Duration is either a time.Duration or nil. + Duration interface{} ) // ToBool returns its argument as a bool. @@ -89,6 +93,16 @@ func ToFloat64(v Float64) float64 { return x } +// ToDuration returns its argument as a time.Duration. +// It panics if its argument is nil or not a time.Duration. +func ToDuration(v Duration) time.Duration { + x, ok := v.(time.Duration) + if !ok { + doPanic("Duration", v) + } + return x +} + func doPanic(capType string, v interface{}) { panic(fmt.Sprintf("optional.%s value should be %s, got %T", capType, strings.ToLower(capType), v)) } -- cgit v1.2.3