Move deps from _workspace/ to vendor/
godep restore pushd $GOPATH/src/github.com/appc/spec git co master popd go get go4.org/errorutil rm -rf Godeps godep save ./... git add vendor git add -f $(git ls-files --other vendor/) git co -- Godeps/LICENSES Godeps/.license_file_state Godeps/OWNERS
This commit is contained in:
50
vendor/github.com/hawkular/hawkular-client-go/metrics/helpers.go
generated
vendored
Normal file
50
vendor/github.com/hawkular/hawkular-client-go/metrics/helpers.go
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
func ConvertToFloat64(v interface{}) (float64, error) {
|
||||
switch i := v.(type) {
|
||||
case float64:
|
||||
return float64(i), nil
|
||||
case float32:
|
||||
return float64(i), nil
|
||||
case int64:
|
||||
return float64(i), nil
|
||||
case int32:
|
||||
return float64(i), nil
|
||||
case int16:
|
||||
return float64(i), nil
|
||||
case int8:
|
||||
return float64(i), nil
|
||||
case uint64:
|
||||
return float64(i), nil
|
||||
case uint32:
|
||||
return float64(i), nil
|
||||
case uint16:
|
||||
return float64(i), nil
|
||||
case uint8:
|
||||
return float64(i), nil
|
||||
case int:
|
||||
return float64(i), nil
|
||||
case uint:
|
||||
return float64(i), nil
|
||||
case string:
|
||||
f, err := strconv.ParseFloat(i, 64)
|
||||
if err != nil {
|
||||
return math.NaN(), err
|
||||
}
|
||||
return f, err
|
||||
default:
|
||||
return math.NaN(), fmt.Errorf("Cannot convert %s to float64", i)
|
||||
}
|
||||
}
|
||||
|
||||
// Returns milliseconds since epoch
|
||||
func UnixMilli(t time.Time) int64 {
|
||||
return t.UnixNano() / 1e6
|
||||
}
|
Reference in New Issue
Block a user