mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-11-03 23:40:03 +00:00 
			
		
		
		
	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
		
			
				
	
	
		
			51 lines
		
	
	
		
			902 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			902 B
		
	
	
	
		
			Go
		
	
	
	
	
	
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
 | 
						|
}
 |