Ai
1 Star 0 Fork 0

CNCF/devstatscode

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
convert.go 714 Bytes
Copy Edit Raw Blame History
Lukasz Gryglicki authored 2019-03-18 20:33 +08:00 . Fixing package name and tests
package devstatscode
import "math"
// GetFloatFromInterface if an interface is of numeric type, return its value as float64
func GetFloatFromInterface(i interface{}) (float64, bool) {
switch i := i.(type) {
case float64:
return i, true
case float32:
return float64(i), true
case int64:
return float64(i), true
case int32:
return float64(i), true
case int16:
return float64(i), true
case int8:
return float64(i), true
case int:
return float64(i), true
case uint64:
return float64(i), true
case uint32:
return float64(i), true
case uint16:
return float64(i), true
case uint8:
return float64(i), true
case uint:
return float64(i), true
default:
return math.NaN(), false
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cncf/devstatscode.git
git@gitee.com:cncf/devstatscode.git
cncf
devstatscode
devstatscode
master

Search