util

package module
v0.0.0-...-a28f42a Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2015 License: MIT Imports: 13 Imported by: 0

README

util

usefull tools collection

Documentation

Overview

author: sunsc time: 2015-07-29 positon:ShangHai License: MIT

Index

Constants

View Source
const (
	KindTime reflect.Kind = iota + 1000000000
	KindDuration
)

Variables

This section is empty.

Functions

func Bool

func Bool(value interface{}) bool

Tries to convert the argument into a bool. Returns false if any error occurs.

func Bytes

func Bytes(val interface{}) []byte

Tries to convert the argument into a []byte array. Returns []byte{} if any error occurs.

func Convert

func Convert(value interface{}, t reflect.Kind) (interface{}, error)

Tries to convert the argument into a reflect.Kind element.

func Duration

func Duration(val interface{}) time.Duration

Tries to convert the argument into a time.Duration value. Returns time.Duration(0) if any error occurs.

func FindString

func FindString(eles []string, ele string, skip int) int

func Float64

func Float64(val interface{}) float64

Tries to convert the argument into a float64. Returns float64(0.0) if any error occurs.

func GenerateStringSlice

func GenerateStringSlice(element string, size int) []string

func Int64

func Int64(val interface{}) int64

Tries to convert the argument into an int64. Returns int64(0) if any error occurs.

func IsLeapYear

func IsLeapYear(year int) bool

func IsLegalMD5Code

func IsLegalMD5Code(code string) bool

func JoinStringSlices

func JoinStringSlices(slice1, slice2 []string, sep string) string

func List

func List(val interface{}) []interface{}

func Map

func Map(val interface{}) map[string]interface{}

func MonthDays

func MonthDays(year, month int) int

func ParseJoinedStringSlice

func ParseJoinedStringSlice(s, sep string) (all, slice1, slice2 []string)

func RandString

func RandString(slice []string) string

func Recover

func Recover(desc string)

func RemoveDuplicate

func RemoveDuplicate(slice []string) []string

func RoundFloat64

func RoundFloat64(val float64, prec int) float64

四舍五入

func String

func String(val interface{}) string

Tries to convert the argument into a string. Returns "" if any error occurs.

func Time

func Time(val interface{}) time.Time

Converts a date string into a time.Time value, several date formats are tried.

func Uint64

func Uint64(val interface{}) uint64

Tries to convert the argument into an uint64. Returns uint64(0) if any error occurs.

Types

type Value

type Value string

func (Value) As

func (this Value) As(value interface{}) (err error)

this function for turn the right value json encoding format

func (Value) Bool

func (this Value) Bool() bool

func (Value) Byte

func (this Value) Byte() byte

func (Value) Bytes

func (this Value) Bytes() []byte

func (Value) Duration

func (this Value) Duration() time.Duration

func (Value) Float32

func (this Value) Float32() float32

func (Value) Float64

func (this Value) Float64() float64

func (Value) Int

func (this Value) Int() int

func (Value) Int16

func (this Value) Int16() int16

func (Value) Int32

func (this Value) Int32() int32

func (Value) Int64

func (this Value) Int64() int64

func (Value) Int8

func (this Value) Int8() int8

func (Value) IsEmpty

func (this Value) IsEmpty() bool

func (Value) String

func (this Value) String() string

func (Value) Time

func (this Value) Time() time.Time

func (Value) UInt

func (this Value) UInt() uint

func (Value) UInt16

func (this Value) UInt16() uint16

func (Value) UInt32

func (this Value) UInt32() uint32

func (Value) UInt64

func (this Value) UInt64() uint64

func (Value) UInt8

func (this Value) UInt8() uint8

Jump to

Keyboard shortcuts

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