1 Star 0 Fork 0

zhuchance/kubernetes

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
helpers.go 902 Bytes
一键复制 编辑 原始数据 按行查看 历史
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
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/meoom/kubernetes.git
git@gitee.com:meoom/kubernetes.git
meoom
kubernetes
kubernetes
v1.2.2-beta.0

搜索帮助

Cb406eda 1850385 E526c682 1850385