Documentation ¶
Overview ¶
Package common contains various helper functions.
Index ¶
- Constants
- func Bytes2Hex(d []byte) string
- func CopyBytes(b []byte) (copiedBytes []byte)
- func FromHex(s string) []byte
- func HasHexPrefix(str string) bool
- func Hex2Bytes(str string) []byte
- func Hex2BytesFixed(str string, flen int) []byte
- func IsHex(str string) bool
- func IsHexCharacter(c byte) bool
- func LeftPadBytes(slice []byte, l int) []byte
- func RightPadBytes(slice []byte, l int) []byte
- func ToHex(b []byte) stringdeprecated
- func ToHexArray(b [][]byte) []string
- type Attribute
- type Duration
- func (d *Duration) Contain(other *Duration) bool
- func (d *Duration) ContainTime(time Timestamp) bool
- func (d *Duration) Contained(other *Duration) bool
- func (d *Duration) DeepCopy() *Duration
- func (d *Duration) ToBytes() []byte
- func (d *Duration) ToJson() []byte
- func (d *Duration) ToMap() map[string]interface{}
- func (d *Duration) ToString() string
- type IntSet
- type MyTimer
- type Timestamp
- type Uint64Set
Constants ¶
View Source
const MaxTimestamp = Timestamp(common.MaxUint64)
Variables ¶
This section is empty.
Functions ¶
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func HasHexPrefix ¶
hasHexPrefix validates str begins with '0x' or '0X'.
func Hex2BytesFixed ¶
Hex2BytesFixed returns bytes of a specified fixed length flen.
func IsHexCharacter ¶
isHexCharacter returns bool of c being a valid hexadecimal.
func LeftPadBytes ¶
LeftPadBytes zero-pads slice to the left up to length l.
func RightPadBytes ¶
RightPadBytes zero-pads slice to the right up to length l.
func ToHexArray ¶
ToHexArray creates a array of hex-string based on []byte
Types ¶
type Attribute ¶
func GenerateTestAttribute ¶
func GenerateTestAttribute() *Attribute
func NewAttribute ¶
type Duration ¶
Duration represents a duration between start and end
func GenerateTestDuration ¶
func GenerateTestDuration() *Duration
func NewDuration ¶
func (*Duration) ContainTime ¶
type MyTimer ¶
type MyTimer struct { Name string Delay uint64 Target func() Timer *time.Timer Running bool RunningMu sync.Mutex // contains filtered or unexported fields }
func NewMyTimer ¶
type Timestamp ¶
type Timestamp uint64
func BytesToTimestamp ¶
func CurrentTime ¶
func CurrentTime() Timestamp
func JsonToTimestamp ¶
func RandomTimestamp ¶
func RandomTimestamp() Timestamp
func TimestampFromUint64 ¶
type Uint64Set ¶
type Uint64Set struct {
// contains filtered or unexported fields
}
func NewUint64Set ¶
func NewUint64Set() *Uint64Set
Click to show internal directories.
Click to hide internal directories.