valutil

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(any interface{}) (bool, error)

Bool 将任意值转成 bool 如果传入值是 boolean,直接强制转换返回; 如果传入值是 string,则按以下规则转换:

"true, yes" -> true
"false, no" -> false
"" -> false
"0.0···001 ... 1 ... ∞" -> true
"-∞ ... -1 ... -0.1 ... 0" -> false
"other word" -> ERROR

如果传入值是 数字,大于零返回 true,否则返回 false

0.0···001 ... 1 ... ∞ -> true
-∞ ... -1 ... -0.1 ... 0 -> false

如果传入值是其他类型,则返回 ERROR

func Int

func Int(any interface{}) (int, error)

Int 将任意值转成 int 如果输入值是 数字,则直接转换; 如果输入值是 boolean,则 true 转为 1;false 转为 0; 如果输入值是 string,则按字符串转换规则 否则抛出 ERROR

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL