37 Star 209 Fork 108

狂奔的蜗牛./anytunnel

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
convert.go 1.28 KB
一键复制 编辑 原始数据 按行查看 历史
arraykeys 提交于 2019-08-08 17:13 +08:00 . init
package utils
import "strconv"
type Convert struct{}
func NewConvert() *Convert {
return &Convert{}
}
// bool 转化为字符串
func (convert *Convert) BoolToString(boolValue bool) string {
if boolValue == true {
return "true"
} else {
return "false"
}
}
//bool 转化为 int
func (convert *Convert) BoolToInt(boolValue bool) int {
if boolValue == true {
return 1
} else {
return 0
}
}
//int 转化为 bool
func (convert *Convert) IntToBool(number int) bool {
if number == 0 {
return false
} else {
return true
}
}
//int 转化为字符串
//base 范围 2-32 进制
func (convert *Convert) IntToString(number int64, base int) string {
return strconv.FormatInt(number, base)
}
//string to int(10进制)
func (convert *Convert) StringToInt(str string) int {
intValue, _ := strconv.Atoi(str)
return intValue
}
// string to int64(10进制)
func (convert *Convert) StringToInt64(str string) int64 {
intValue, _ := strconv.ParseInt(str, 10, 64)
return intValue
}
//int 转化为10进制字符串 IntToString(number, 10)
func (convert *Convert) IntToTenString(number int) string {
return strconv.Itoa(number)
}
// float 转化为字符串
func (convert *Convert) FloatToString(f float64, fmt byte, prec, bitSize int) string {
return strconv.FormatFloat(f, fmt, prec, bitSize)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/snail/anytunnel.git
git@gitee.com:snail/anytunnel.git
snail
anytunnel
anytunnel
8296c84158a6

搜索帮助