Documentation ¶
Overview ¶
Package util random string https://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-go
Index ¶
- Constants
- Variables
- func AnyToDecimal(b []int64, base int) int64
- func ArrayContainsString(a []string, e string) bool
- func ArrayDistinctInt(src []int) []int
- func ArrayIntersectString(a []string, b []string) []string
- func ArrayJoinInt(a []int, sep string) string
- func ArrayJoinUint32(a []uint32, sep string) string
- func ArrayReverseInt64(a []int64)
- func ArrayReverseString(a []string)
- func ArraySortAscInt(src []int)
- func ArraySortDescInt(src []int)
- func ArraySymDiffString(a []string, b []string) []string
- func ArrayUnionString(a []string, b []string) []string
- func BytesCombine(pBytes ...[]byte) []byte
- func BytesToHex(src []byte) string
- func BytesToUint32(src []byte) (dst uint32, err error)
- func CST() *time.Location
- func CSTE() (*time.Location, error)
- func CurGoroutineID() uint64
- func DailyTask(ctx context.Context, hour, minute, second int, loc *time.Location, ...)
- func DailyTaskCST(ctx context.Context, hour, minute, second int, callback CallbackFunc)
- func DailyTaskUTC(ctx context.Context, hour, minute, second int, callback CallbackFunc)
- func DecimalToAny(i int64, base int) []int64
- func GbkToUtf8(in []byte) ([]byte, error)
- func GetOriginalDst(c *net.TCPConn) (string, uint16, error)
- func GetUUIDV1() string
- func GetUUIDV1WithoutLine() string
- func HmacSha1(p, key []byte) ([]byte, error)
- func HmacSha256(p, key []byte) ([]byte, error)
- func InitInterface(i interface{}) interface{}
- func InitPointer(src reflect.Type) (dst reflect.Value)
- func InitWithZeroValue(src reflect.Type) (dst reflect.Value)
- func InitWithZeroValueExcludePtr(src reflect.Type) (dst reflect.Value)
- func IsExported(name string) bool
- func IsExportedOrBuiltinType(t reflect.Type) bool
- func Md5(p []byte) ([]byte, error)
- func Md5ToHex(p []byte) (string, error)
- func Millisecond() int64
- func PeriodContains(t int64, p Period) bool
- func PeriodPartition(p Period, interval int64) map[int64]Period
- func PeriodsContains(t int64, ps []Period) bool
- func PeriodsPartition(ps []Period, interval int64) map[int64][]Period
- func PeriodsSortAsc(ps []Period)
- func PeriodsSortDesc(ps []Period)
- func RandStringBytes(n int) string
- func RandStringBytesMask(n int) string
- func RandStringBytesMaskImpr(n int) string
- func RandStringBytesMaskImprSrc(n int) string
- func RandStringBytesRmndr(n int) string
- func RandStringRunes(n int) string
- func RandomBytes(n int) []byte
- func RandomBytesE(n int) ([]byte, error)
- func RandomString(source string, n int) string
- func RandomStringByDigital(n int) string
- func RandomStringByLetter(n int) string
- func RandomStringByLetterAndDigital(n int) string
- func SetStructField(v interface{}, fieldValue interface{}, fieldNames ...string) bool
- func Sha256(p []byte) ([]byte, error)
- func Sha256ToHex(p []byte) (string, error)
- func TrimSpaceAndSlash(s string) string
- func Uint32ToByte(src uint32) (dst []byte, err error)
- func Utf8ToGbk(in []byte) ([]byte, error)
- type CallbackFunc
- type Node
- func (n *Node) AddChild(c *Node)
- func (n *Node) BFS(fn func(*Node))
- func (n *Node) DFSPostOrder(fn func(*Node))
- func (n *Node) DFSPreOrder(fn func(*Node))
- func (n *Node) Degree() int
- func (n *Node) Depth() int
- func (n *Node) Get(key string) (interface{}, bool)
- func (n *Node) Height() int
- func (n *Node) Insert(key string, compare func(interface{}, interface{}) bool, values ...string) *Node
- func (n *Node) Level() int
- func (n *Node) Put(key string, value interface{})
- func (n *Node) Search(key string, compare func(interface{}, interface{}) bool, values ...string) (*Node, bool)
- func (n *Node) String() string
- type Period
- func AddPeriodToResultSet(p Period, rs []Period) []Period
- func NewPeriod(st, et int64) (Period, error)
- func NewPeriods(se ...int64) ([]Period, error)
- func PeriodDifference(b Period, a Period) []Period
- func PeriodIntersection(p1 Period, p2 Period) []Period
- func PeriodMinSuperSet(p Period, interval int64) Period
- func PeriodUnion(p1 Period, p2 Period) []Period
- func PeriodsDifference(b []Period, a []Period) []Period
- func PeriodsIntersection(a []Period, b []Period) []Period
- func PeriodsMinSuperSet(ps []Period, interval int64) []Period
- func PeriodsUnion(a []Period, b []Period) []Period
- type SecurityString
- type StructField
- func (sf *StructField) Bool() (bool, bool)
- func (sf *StructField) BoolE() (bool, bool, error)
- func (sf *StructField) Float64() (float64, bool)
- func (sf *StructField) Float64E() (float64, bool, error)
- func (sf *StructField) Int() (int, bool)
- func (sf *StructField) IntE() (int, bool, error)
- func (sf *StructField) Interface() (interface{}, bool)
- func (sf *StructField) String() (string, bool)
- func (sf *StructField) StringE() (string, bool, error)
- type Tree
- func (t *Tree) BFS(fn func(*Node))
- func (t *Tree) DFSPostOrder(fn func(*Node))
- func (t *Tree) DFSPreOrder(fn func(*Node))
- func (t *Tree) Degree() int
- func (t *Tree) Depth() int
- func (t *Tree) Height() int
- func (t *Tree) Insert(key string, compare func(interface{}, interface{}) bool, values ...string) *Node
- func (t *Tree) Level() int
- func (t *Tree) Search(key string, compare func(interface{}, interface{}) bool, values ...string) (*Node, bool)
- func (t *Tree) String() string
Constants ¶
const ( SO_ORIGINAL_DST = 80 // from linux/include/uapi/linux/netfilter_ipv4.h IP6T_SO_ORIGINAL_DST = 80 // from linux/include/uapi/linux/netfilter_ipv6/ip6_tables.h )
const ( KB MB GB TB PB )
Variables ¶
Functions ¶
func ArrayContainsString ¶
ArrayContainsString string contains
func ArrayIntersectString ¶
ArrayIntersectString string intersect
func ArrayJoinUint32 ¶
ArrayJoinUint32 join uint32 array
func ArrayReverseString ¶
func ArrayReverseString(a []string)
ArrayReverseString stirng array reverse
func ArraySymDiffString ¶
ArraySymDiffString symmetric difference
func ArrayUnionString ¶
ArrayUnionString string union
func BytesToUint32 ¶
BytesToUint32 byte to uint32
func CurGoroutineID ¶
func CurGoroutineID() uint64
CurGoroutineID get current go routine ID ref https://github.com/golang/net/blob/master/http2/gotrack.go#L51 not recommended http://lanlingzi.cn/post/technical/2016/0813_go_gls/
func DailyTask ¶
func DailyTask(ctx context.Context, hour, minute, second int, loc *time.Location, callback CallbackFunc)
DailyTask daily execution
func DailyTaskCST ¶
func DailyTaskCST(ctx context.Context, hour, minute, second int, callback CallbackFunc)
DailyTaskCST DailyTask for CST
func DailyTaskUTC ¶
func DailyTaskUTC(ctx context.Context, hour, minute, second int, callback CallbackFunc)
DailyTaskUTC DailyTask for UTC
func DecimalToAny ¶
DecimalToAny decimal to any ignore positive and negative
func GetOriginalDst ¶
GetOriginalDst Get the original destination of a TCP connection. inspired by github.com/missdeer/avege
func GetUUIDV1WithoutLine ¶
func GetUUIDV1WithoutLine() string
func InitInterface ¶
func InitInterface(i interface{}) interface{}
InitInterface init interface to zero value
func InitWithZeroValue ¶
InitWithZeroValue init type with default value
func InitWithZeroValueExcludePtr ¶
InitWithZeroValueExcludePtr init type with default value if v.Kind() == reflect.Ptr, will init by zero value which point to example var a *int, a is not nil, *a = 0
func IsExported ¶
IsExported Is this an exported - upper case - name?
func IsExportedOrBuiltinType ¶
IsExportedOrBuiltinType Is this type exported or a builtin?
func PeriodContains ¶
PeriodContains judge is t in period
func PeriodPartition ¶
PeriodPartition split period by interval period not support et is negative
func PeriodsContains ¶
PeriodsContains judge is t in periods
func PeriodsPartition ¶
PeriodsPartition split periods by interval
func RandStringBytes ¶
func RandStringBytesMask ¶
func RandStringBytesMaskImpr ¶
func RandStringBytesRmndr ¶
func RandStringRunes ¶
func RandomBytes ¶
func RandomBytesE ¶
RandomBytesE random by rand.Reader it will use cpu more
func RandomString ¶
func RandomStringByDigital ¶ added in v1.1.0
func RandomStringByLetter ¶
func SetStructField ¶
SetStructField v is ptr to struct
func TrimSpaceAndSlash ¶
TrimSpaceAndSlash trim space first, then trim slash
func Uint32ToByte ¶
Uint32ToByte uint32 to byte
Types ¶
type Node ¶
type Node struct { Parent *Node Data map[string]interface{} Children []*Node Format func(*Node) string }
Node definition
func (*Node) BFS ¶
BFS Breadth-First Search (BFS) is an algorithm for traversing or searching tree data structure. It starts at the tree root and explores the neighbor nodes first, before moving to the next level neighbors.
func (*Node) DFSPostOrder ¶
DFSPostOrder Depth-First Search (DFS) is an algorithm for traversing or searching tree data structure. One starts at the root and explores as far as possible along each branch before backtracking. parent comes after children; overall root last
func (*Node) DFSPreOrder ¶
DFSPreOrder Depth-First Search (DFS) is an algorithm for traversing or searching tree data structure. One starts at the root and explores as far as possible along each branch before backtracking. parent comes before children; overall root first
type Period ¶
type Period struct {
// contains filtered or unexported fields
}
Period a length or portion of time. [StartTime, EndTime] StartTime must be >= 0 EndTime negative values represent positive infinity
func AddPeriodToResultSet ¶
AddPeriodToResultSet add a period to result set ResultSet is a set of period, all elements has been union
func PeriodIntersection ¶
PeriodIntersection intersect two period
func PeriodMinSuperSet ¶
PeriodMinSuperSet period mininum super set
func PeriodsDifference ¶
PeriodsDifference b - a
func PeriodsIntersection ¶
PeriodsIntersection intersect two periods
func PeriodsMinSuperSet ¶
PeriodsMinSuperSet periods mininum super set
func PeriodsUnion ¶
PeriodsUnion union two periods
type SecurityString ¶
func NewSecurityString ¶
func NewSecurityString() *SecurityString
func (*SecurityString) Get ¶
func (ss *SecurityString) Get() (data string)
func (*SecurityString) Set ¶
func (ss *SecurityString) Set(data string)
type StructField ¶
type StructField struct { Field reflect.StructField FieldName string FieldValue reflect.Value IsExist bool }
StructField struct filed
func GetStructField ¶
func GetStructField(v interface{}, fieldNames ...string) *StructField
GetStructField get struct field
func (*StructField) Bool ¶
func (sf *StructField) Bool() (bool, bool)
Bool convert StructField to bool
func (*StructField) BoolE ¶
func (sf *StructField) BoolE() (bool, bool, error)
BoolE convert StructField to bool with error
func (*StructField) Float64 ¶
func (sf *StructField) Float64() (float64, bool)
Float64 convert StructField to float64
func (*StructField) Float64E ¶
func (sf *StructField) Float64E() (float64, bool, error)
Float64E convert StructField to float64 with error
func (*StructField) IntE ¶
func (sf *StructField) IntE() (int, bool, error)
IntE convert StructField to int with error
func (*StructField) Interface ¶
func (sf *StructField) Interface() (interface{}, bool)
Interface return StructField value
func (*StructField) String ¶
func (sf *StructField) String() (string, bool)
String convert StructField to string
type Tree ¶
type Tree struct {
Root *Node
}
Tree definition
func (*Tree) BFS ¶
BFS Breadth-First Search (BFS) is an algorithm for traversing or searching tree data structure. It starts at the tree root and explores the neighbor nodes first, before moving to the next level neighbors.
func (*Tree) DFSPostOrder ¶
DFSPostOrder Depth-First Search (DFS) is an algorithm for traversing or searching tree data structure. One starts at the root and explores as far as possible along each branch before backtracking. parent comes after children; overall root last
func (*Tree) DFSPreOrder ¶
DFSPreOrder Depth-First Search (DFS) is an algorithm for traversing or searching tree data structure. One starts at the root and explores as far as possible along each branch before backtracking. parent comes before children; overall root first