Documentation ¶
Index ¶
- Constants
- func AnyToBool(v interface{}) bool
- func AnyToFloat(v interface{}) float64
- func AnyToInt(v interface{}) int
- func AnyToInt16(v interface{}) int16
- func AnyToInt64(v interface{}) int64
- func AnyToInt8(v interface{}) int8
- func AnyToRound(v interface{}, places int) float64
- func AnyToStr(v interface{}) string
- func AnyToTime(v interface{}) time.Time
- func AnyToUInt16(v interface{}) uint16
- func AnyToUInt64(v interface{}) uint64
- func AnyToUInt8(v interface{}) uint8
- func AppDir() string
- func AppFile() string
- func AppPath() string
- func AppTimeLoc() *time.Location
- func AppTimeOffset() int
- func AppTimeZone() string
- func Args() []string
- func BytesToStrUnsafe(rawBytes []byte) string
- func CallAnyMethod(v interface{}, method string) interface{}
- func Exist(path string) bool
- func GetOsDirSpr() string
- func GetOsEndian() binary.ByteOrder
- func GetOsEof() string
- func GetOsFlag() int
- func Hours(hours int) time.Duration
- func IntToTime(value int64) time.Time
- func IsDir(path string) bool
- func IsFile(path string) bool
- func IsValidTime(t time.Time) bool
- func KindOf(v interface{}) reflect.Kind
- func KindToInt64(v interface{}) int64
- func Minutes(minutes int) time.Duration
- func OffsetIndex(index int, size int) int
- func ReadFileByte(path string) ([]byte, error)
- func ReadFileStr(path string) (string, error)
- func RealPathSplitDirFile(path string) (string, string, error)
- func Round(f float64, places int) float64
- func Seconds(seconds int) time.Duration
- func SplitDirFile(path string) (string, string)
- func StrToFInt(value string) int
- func StrToFInt64(value string) int64
- func StrToFloat(value string) float64
- func StrToInt(value string) int
- func StrToIntBool(value string) bool
- func StrToTime(value string, layout string) time.Time
- func TF(format string) string
- func TimesTest(times int, fn func(int)) time.Duration
- func ValueOf(v interface{}) reflect.Value
Constants ¶
View Source
const ( OS_LINUX = iota OS_MAC OS_WIN OS_OTHERS )
Variables ¶
This section is empty.
Functions ¶
func AnyToInt16 ¶
func AnyToInt16(v interface{}) int16
小位数的整型,还是经常会用到的 溢出值,以溢出的最大值处理,而不要作为负数处理 65536 / 2
func AnyToInt64 ¶
func AnyToInt64(v interface{}) int64
转型最好优先转型到最大的值,然后再往底缩进 更精确的做法,应该是根据位长,来做出适当的判断但过度优化,又不如直接用go提供一些方法 所以这个方法只是确保值的有效性转换,性能在能考虑的条件下,才考虑
func AnyToStr ¶
func AnyToStr(v interface{}) string
注意,所有其他的AnyTo转换,都不处理[]byte,因为实际上[]byte的情况会比较复杂,他可能包含了encode/gob的编码格式,也可能是json格式 也可能用户自己打包的,所以我们不做任何处理 但AnyToStr的话还是要处理,尝试最简单的转换
func AnyToUInt16 ¶
func AnyToUInt16(v interface{}) uint16
无负数的小位数整型,其实也是很常用到的,32的就自己手动转吧,uint32能表达的值意境非常大了
func BytesToStrUnsafe ¶
func IsValidTime ¶
go的时间 var t = time.Time {} => t.IsZero() => true var t = time.Unix(0, 0) => t.IsZero() => false
func Round ¶
func StrToTime ¶
将字符串的时间表示,转为时间,注意是类似2014-12-31,不是整型值 如果要指定时区解析,直接调用time.ParseInLocation吧
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.