jutil

package
v0.0.0-...-6f5c55b Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPrefixSuffixLen = 8
)

Variables

This section is empty.

Functions

func Abs

func Abs(x int) int

func Abs64

func Abs64(x int64) int64

func BytePad

func BytePad(b []byte, size int) []byte

func BytePadPrefix

func BytePadPrefix(b []byte, size int) []byte

BytePadPrefix will use 2 bytes for prefix, so input data must not be greater than size-2.

func ByteReverse

func ByteReverse(d []byte) []byte

func ByteUnPad

func ByteUnPad(b []byte) []byte

func CombineBytes

func CombineBytes(slices ...[]byte) []byte

https://stackoverflow.com/a/40678026/744298

func CopyTimeToDate

func CopyTimeToDate(src, dst time.Time) time.Time

func CountMatches

func CountMatches(full, part string) int

func CountMatchesRegex

func CountMatchesRegex(full, regex string) int

func DateGTE

func DateGTE(a, b time.Time) bool

func DateLTE

func DateLTE(a, b time.Time) bool

func DateMax

func DateMax(a, b time.Time) time.Time

func DateMin

func DateMin(a, b time.Time) time.Time

func FastHash32

func FastHash32(s string) []byte

func FastHash32Uint

func FastHash32Uint(s string) uint32

func GetBoolFromString

func GetBoolFromString(s string) bool

func GetByteDuration

func GetByteDuration(b []byte) time.Duration

func GetByteMd5Int

func GetByteMd5Int(b []byte) uint

func GetByteTime

func GetByteTime(b []byte) time.Time

func GetDaySeconds

func GetDaySeconds(t time.Time) time.Duration

func GetDaysInMonth

func GetDaysInMonth(t time.Time) int

func GetDurationByte

func GetDurationByte(d time.Duration) []byte

func GetFloatFromString

func GetFloatFromString(s string, size int) float64

func GetInt

func GetInt(data []byte) int

func GetInt32

func GetInt32(data []byte) int32

func GetInt32Data

func GetInt32Data(i int32) []byte

func GetInt32FromString

func GetInt32FromString(s string) int32

func GetInt64

func GetInt64(d []byte) int64

func GetInt64Big

func GetInt64Big(d []byte) int64

func GetInt64Data

func GetInt64Data(i int64) []byte

func GetInt64DataBig

func GetInt64DataBig(i int64) []byte

func GetInt64FromString

func GetInt64FromString(s string) int64

func GetIntData

func GetIntData(i int) []byte

func GetIntFromString

func GetIntFromString(s string) int

func GetIpString

func GetIpString(ip net.IP, port uint16) string

func GetMatches

func GetMatches(full, regex string) []string

func GetSha256Hash

func GetSha256Hash(script []byte) []byte

func GetTime

func GetTime(ts time.Time) string

func GetTimeAgo

func GetTimeAgo(ts time.Time) string

func GetTimeAgoShort

func GetTimeAgoShort(ts time.Time) string

func GetTimeByte

func GetTimeByte(t time.Time) []byte

func GetTimezoneTime

func GetTimezoneTime(ts time.Time, timezone string) string

func GetTimezoneTimeShort

func GetTimezoneTimeShort(ts time.Time, timezone string) string

func GetUInt16FromString

func GetUInt16FromString(s string) uint16

func GetUInt32FromString

func GetUInt32FromString(s string) uint32

func GetUInt64FromString

func GetUInt64FromString(s string) uint64

func GetUIntFromString

func GetUIntFromString(s string) uint

func GetUint

func GetUint(data []byte) uint

func GetUint16

func GetUint16(data []byte) uint16

func GetUint16Data

func GetUint16Data(i uint16) []byte

func GetUint32

func GetUint32(data []byte) uint32

func GetUint32Data

func GetUint32Data(i uint32) []byte

func GetUint64

func GetUint64(data []byte) uint64

func GetUint64Data

func GetUint64Data(i uint64) []byte

func GetUintData

func GetUintData(i uint) []byte

func GetUnique

func GetUnique(n int) string

func GetUniqueHex

func GetUniqueHex(n int) string

func HasPrefix

func HasPrefix(b []byte, prefix []byte) bool

func InByteArray

func InByteArray(needle []byte, haystack [][]byte) bool

func InUintSlice

func InUintSlice(needle uint, haystack []uint) bool

func IsMatch

func IsMatch(full, part string) bool

func IsMatchRegex

func IsMatchRegex(full, regex string) bool

func IsNil

func IsNil(a interface{}) bool

func MaxFloat64

func MaxFloat64(x, y float64) float64

func MaxInt

func MaxInt(x, y int) int

func MaxInt64

func MaxInt64(x, y int64) int64

func MinInt

func MinInt(x, y int) int

func MinInt64

func MinInt64(x, y int64) int64

func RemoveDupeStrings

func RemoveDupeStrings(stringList []string) []string

func RemoveDupes

func RemoveDupes(uints []uint) []uint

func RemoveDupesAndEmpties

func RemoveDupesAndEmpties(data [][]byte) [][]byte

func Replace

func Replace(full, regex, replace string) string

func ReverseStringSlice

func ReverseStringSlice(slice []string) []string

func RoundMonth

func RoundMonth(t time.Time) time.Time

func RoundTime

func RoundTime(t time.Time, days int) time.Time

func RoundWeek

func RoundWeek(t time.Time) time.Time

func ShortHash

func ShortHash(hash string) string

func ShortHashLen

func ShortHashLen(hash string, prefixSuffixLen int) string

func StringInSlice

func StringInSlice(needle string, haystack []string) bool

func TimeInSlice

func TimeInSlice(item time.Time, times []time.Time) bool

func UnescapeByteString

func UnescapeByteString(s string) []byte

Types

type Bitwise

type Bitwise []byte

func (*Bitwise) Clear

func (b *Bitwise) Clear(index int, flag byte)

func (Bitwise) Has

func (b Bitwise) Has(index int, flag byte) bool

func (*Bitwise) Set

func (b *Bitwise) Set(index int, flag byte)

func (*Bitwise) Toggle

func (b *Bitwise) Toggle(index int, flag byte)

type Catch

type Catch struct {
	Panic interface{}
}

func (*Catch) Try

func (c *Catch) Try(f func())

type DateDiff

type DateDiff struct {
	Year  int
	Month int
	Day   int
	Hour  int
	Min   int
	Sec   int
	// contains filtered or unexported fields
}

func (DateDiff) DaysRounded

func (d DateDiff) DaysRounded() int

func (DateDiff) Months

func (d DateDiff) Months() float32

func (DateDiff) String

func (d DateDiff) String() string

Jump to

Keyboard shortcuts

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