common

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const TimeFormat = "2006-01-02 15:04:05"
View Source
const TimeZoneFormat = "Z07"

Variables

View Source
var EPSILON float64 = 0.0000001

Functions

func AddList

func AddList(left []uint16, right []uint16) []uint16

AddList: left + right ex: left=[1,2,3], right=[2,3,4]. result=[1,2,3,2,3,4]

func CharsToString

func CharsToString(ca []int8) string

func CombineList

func CombineList(left []uint16, right []uint16) []uint16

CombineList: left + right, remove duplicate elements ex: left=[1,2,3], right=[2,3,4]. result=[1,2,3,4]

func CounterDiff

func CounterDiff(a, b, max uint64) uint64

CounterDiff considering overflow

func DiffList

func DiffList(left []uint16, right []uint16) []uint16

DiffList : different list, return: left - right ex: left=[1,2,3], right=[2,3,4]. result=[1]

func FirstCharToLower

func FirstCharToLower(str string) string

func FirstCharToUpper

func FirstCharToUpper(str string) string

FirstCharToUpper

func FloatEquals

func FloatEquals(a, b float64) bool

FloatEquals compare float64 values, can has EPSILON precision

func GetDateTime

func GetDateTime() (localtime string, utctime string, zone int)

func GetLocation

func GetLocation() (country, city string, err error)

func GetUTCTimestamp

func GetUTCTimestamp() string

func Ip2uint32Littlendian

func Ip2uint32Littlendian(ip string) uint32

Ip2uint32Littlendian transport ip to uint32 127.0.0.1<=>16777343

func IsValidUrl

func IsValidUrl(str string) bool

IsValidUrl tests a string to determine if it is a url or not.

func MD5

func MD5(text string) string

MD5 make md5 to string

func MakePifFilePath

func MakePifFilePath(procName, runPath string) (string, error)

MakePifFilePath make a new pid path default pid lock file: procPath/pid.file or pid lock file: pidFilePath/procName.pid if set runPath

func MaxUInt

func MaxUInt(x, y uint64) uint64

Max unsigned integer

func MinUInt

func MinUInt(x, y uint64) uint64

Min unsigned integer

func PrintStruct

func PrintStruct(data interface{})

PrintStruct print struct to json just for debug

func ReadLines

func ReadLines(filename string) ([]string, error)

func ScanPidLine

func ScanPidLine(content []byte) int

reference from lockfile

func TryToFloat64

func TryToFloat64(number interface{}) (float64, bool)

TryToFloat64 try int, uint, float numbers to float64. not work with string and others type

func TryToInt

func TryToInt(key string) interface{}

TryToInt converts value to int, if not a number, return the key

func TryToNumber

func TryToNumber(key string) interface{}

TryToNumber converts string to number, if not a number, return the key

func UInt32ToipLittlendian

func UInt32ToipLittlendian(nn uint32) string

UInt32ToipLittlendian transport uint to ip 16777343 <=> 127.0.0.1

func ValidateIPAddress

func ValidateIPAddress(val string) bool

ValidateIPAddress validates an Ip address.

Types

type DateTime

type DateTime struct {
	Zone     int    `json:"timezone"`
	Datetime string `json:"datetime"`
	UTCTime  string `json:"utctime"`
	Country  string `json:"country"`
	City     string `json:"city"`
}

DateTime

type ErrNotImplemented

type ErrNotImplemented struct {
	OS string
}

ErrNotImplemented

func (ErrNotImplemented) Error

func (e ErrNotImplemented) Error() string

type InterfaceSet

type InterfaceSet struct {
	// contains filtered or unexported fields
}

InterfaceSet

func NewInterfaceSet

func NewInterfaceSet() InterfaceSet

func (*InterfaceSet) Copy

func (s *InterfaceSet) Copy() *InterfaceSet

func (*InterfaceSet) Delete

func (s *InterfaceSet) Delete(key interface{})

func (*InterfaceSet) Exist

func (s *InterfaceSet) Exist(key interface{}) bool

func (*InterfaceSet) Insert

func (s *InterfaceSet) Insert(key interface{})

func (*InterfaceSet) Keys

func (s *InterfaceSet) Keys() map[interface{}]bool

func (*InterfaceSet) Size

func (s *InterfaceSet) Size() int

type MapStr

type MapStr = common.MapStr

type Set

type Set struct {
	// contains filtered or unexported fields
}

Set is a string set

func NewSet

func NewSet() Set

func (*Set) Copy

func (s *Set) Copy() *Set

func (*Set) Delete

func (s *Set) Delete(key string)

func (*Set) Exist

func (s *Set) Exist(key string) bool

func (*Set) Insert

func (s *Set) Insert(key string)

func (*Set) Keys

func (s *Set) Keys() map[string]bool

func (*Set) Size

func (s *Set) Size() int

Jump to

Keyboard shortcuts

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