baseutils

package
v1.0.68 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DurationDay      = time.Hour * 24
	DurationMonth    = DurationDay * 30
	MaxDurationMonth = DurationDay * 31
	DurationYear     = DurationDay * 365
	MaxDurationYear  = DurationDay * 366
)

Variables

View Source
var ReflectTimeType = stl.ReflectType[time.Time]()

Functions

func AlignNextTime added in v1.0.8

func AlignNextTime(base time.Time, interval time.Duration, offset time.Duration) time.Time

func Base64Decode added in v1.0.6

func Base64Decode(enc *base64.Encoding, data []byte) ([]byte, error)

func Base64Encode added in v1.0.6

func Base64Encode(enc *base64.Encoding, data []byte) []byte

func DayOf added in v1.0.58

func DayOf(t time.Time) time.Time

func DereferenceReflectPointer added in v1.0.35

func DereferenceReflectPointer(ptr reflect.Value) (result reflect.Value, ok bool)

func DereferenceReflectPointerWithError added in v1.0.35

func DereferenceReflectPointerWithError(ptr reflect.Value) (result reflect.Value, err error)

func GenerateRsaKey added in v1.0.6

func GenerateRsaKey(bits int) (publicKey, privateKey []byte, err error)

func GetYear2050 added in v1.0.58

func GetYear2050() time.Time

func GetYear3000 added in v1.0.58

func GetYear3000() time.Time

func GetYear5000 added in v1.0.58

func GetYear5000() time.Time

func HashData added in v1.0.6

func HashData(hash crypto.Hash, datas ...[]byte) ([]byte, error)

func HashDataSilently added in v1.0.6

func HashDataSilently(hash crypto.Hash, datas ...[]byte) []byte

func IteratorDataToTypelessSliceByReflect added in v1.0.35

func IteratorDataToTypelessSliceByReflect(data any) ([]any, error)

func IteratorDataToTypelessSliceByReflectValue added in v1.0.35

func IteratorDataToTypelessSliceByReflectValue(data reflect.Value) ([]any, error)

func MapKeyValuePairPtrsByReflect added in v1.0.35

func MapKeyValuePairPtrsByReflect(m any) (stl.KeyValuePairPtrs[any, any], error)

func MapKeyValuePairPtrsByReflectValue added in v1.0.35

func MapKeyValuePairPtrsByReflectValue(m reflect.Value) stl.KeyValuePairPtrs[any, any]

func MapKeyValuePairsByReflect added in v1.0.35

func MapKeyValuePairsByReflect(m any) (stl.KeyValuePairs[any, any], error)

func MapKeyValuePairsByReflectValue added in v1.0.35

func MapKeyValuePairsByReflectValue(m reflect.Value) stl.KeyValuePairs[any, any]

func MapListByReflect added in v1.0.35

func MapListByReflect[T any](datas any, mapper func(data any) T) ([]T, error)

func MapListByReflectValue added in v1.0.35

func MapListByReflectValue[T any](datas reflect.Value, mapper func(data any) T) []T

func MapListToAnysByReflect added in v1.0.35

func MapListToAnysByReflect(datas any) ([]any, error)

func MapListToAnysByReflectValue added in v1.0.35

func MapListToAnysByReflectValue(datas reflect.Value) []any

func MapMapWithReflect added in v1.0.35

func MapMapWithReflect[T any](m any, mapper func(stl.KeyValuePair[any, any]) T) ([]T, error)

func MapMapWithReflectValue added in v1.0.35

func MapMapWithReflectValue[T any](m reflect.Value, mapper func(stl.KeyValuePair[any, any]) T) []T

func MaxTime added in v1.0.32

func MaxTime(times ...time.Time) time.Time

func MinTime added in v1.0.32

func MinTime(times ...time.Time) time.Time

func NewHash added in v1.0.6

func NewHash(hash crypto.Hash) (hash.Hash, error)

func NewTimes added in v1.0.33

func NewTimes(times ...time.Time) []time.Time

func ParseJsonRawMessage added in v1.0.24

func ParseJsonRawMessage[Data any](message JsonRawMessage) (data Data, err error)

func ParseJsonRawMessageAsPointer added in v1.0.24

func ParseJsonRawMessageAsPointer[Ptr *Data, Data any](message JsonRawMessage) (Ptr, error)

func ParseNetloc added in v1.0.11

func ParseNetloc(loc string, defaultAddr string, defaultPort int) (addr string, port int, err error)

func Pkcs5Padding added in v1.0.6

func Pkcs5Padding(data []byte, blockSize int) []byte

func Pkcs5Unpadding added in v1.0.6

func Pkcs5Unpadding(data []byte) []byte

func SortTimes added in v1.0.33

func SortTimes(times ...time.Time) []time.Time

func Today added in v1.0.58

func Today() time.Time

func Tomorrow added in v1.0.58

func Tomorrow() time.Time

func WrapTimeFields added in v1.0.48

func WrapTimeFields(data any, wrapper func(time.Time) time.Time) error

func WrapTimeFieldsByReflectValue added in v1.0.48

func WrapTimeFieldsByReflectValue(value reflect.Value, wrapper func(time.Time) time.Time) error

func Yesterday added in v1.0.58

func Yesterday() time.Time

Types

type AesCipher added in v1.0.6

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

func NewAesCipher added in v1.0.6

func NewAesCipher(key []byte, bits int) (*AesCipher, error)

func (*AesCipher) Decrypt added in v1.0.6

func (a *AesCipher) Decrypt(cipherdata []byte, b64 bool) ([]byte, error)

func (*AesCipher) Encrypt added in v1.0.6

func (a *AesCipher) Encrypt(plaintext []byte, b64 bool) ([]byte, error)

type BadTypeError added in v1.0.35

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

func NewBadTypeError added in v1.0.35

func NewBadTypeError(expected, given string) BadTypeError

func NewBadTypeErrorWithGivenReflectType added in v1.0.35

func NewBadTypeErrorWithGivenReflectType(expected, given reflect.Type) BadTypeError

func NewBlankBadTypeError added in v1.0.35

func NewBlankBadTypeError() BadTypeError

func (BadTypeError) Error added in v1.0.35

func (e BadTypeError) Error() string

func (BadTypeError) WithExpected added in v1.0.35

func (err BadTypeError) WithExpected(expected string) BadTypeError

func (BadTypeError) WithExpectedReflectType added in v1.0.35

func (err BadTypeError) WithExpectedReflectType(expected reflect.Type) BadTypeError

func (BadTypeError) WithGiven added in v1.0.35

func (err BadTypeError) WithGiven(given string) BadTypeError

func (BadTypeError) WithGivenReflectType added in v1.0.35

func (err BadTypeError) WithGivenReflectType(given reflect.Type) BadTypeError

type CookieNotFoundError

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

func NewCookieNotFoundError

func NewCookieNotFoundError(name string) CookieNotFoundError

func (CookieNotFoundError) Error

func (e CookieNotFoundError) Error() string

func (CookieNotFoundError) Name

func (e CookieNotFoundError) Name() string

type EnvironmentVariableNotFoundError

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

func NewEnvironmentVariableNotFoundError

func NewEnvironmentVariableNotFoundError(name string) EnvironmentVariableNotFoundError

func (EnvironmentVariableNotFoundError) Error

func (EnvironmentVariableNotFoundError) Name

type Errors added in v1.0.8

type Errors = stl.Errors

type GenericNotFoundError added in v1.0.25

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

func NewGenericNotFoundError added in v1.0.25

func NewGenericNotFoundError(t, name string) GenericNotFoundError

func (GenericNotFoundError) Error added in v1.0.25

func (e GenericNotFoundError) Error() string

func (GenericNotFoundError) Name added in v1.0.25

func (e GenericNotFoundError) Name() string

func (GenericNotFoundError) Type added in v1.0.25

func (e GenericNotFoundError) Type() string

type IntraDayTime added in v1.0.58

type IntraDayTime time.Duration

func MustParseFormattedIntraDayTime added in v1.0.58

func MustParseFormattedIntraDayTime(layout, value string) IntraDayTime

func MustParseIntraDayTime added in v1.0.58

func MustParseIntraDayTime(s string) IntraDayTime

func ParseFormattedIntraDayTime added in v1.0.58

func ParseFormattedIntraDayTime(layout, value string) (IntraDayTime, error)

func ParseIntraDayTime added in v1.0.58

func ParseIntraDayTime(s string) (IntraDayTime, error)

func (IntraDayTime) Duration added in v1.0.58

func (t IntraDayTime) Duration() time.Duration

func (IntraDayTime) Format added in v1.0.58

func (t IntraDayTime) Format(layout string) string

func (IntraDayTime) MarshalJSON added in v1.0.58

func (t IntraDayTime) MarshalJSON() ([]byte, error)

func (IntraDayTime) Parts added in v1.0.58

func (t IntraDayTime) Parts() (int, int, int, int)

func (IntraDayTime) String added in v1.0.58

func (t IntraDayTime) String() string

func (*IntraDayTime) UnmarshalJSON added in v1.0.58

func (t *IntraDayTime) UnmarshalJSON(data []byte) error

type JsonAny added in v1.0.24

type JsonAny = any

type JsonArray added in v1.0.24

type JsonArray = []JsonAny

type JsonMap added in v1.0.24

type JsonMap = JsonObject

type JsonObject added in v1.0.24

type JsonObject = map[string]JsonAny

type JsonRawMessage added in v1.0.24

type JsonRawMessage struct {
	json.RawMessage
}

func (JsonRawMessage) UnmarshalAsInt added in v1.0.24

func (message JsonRawMessage) UnmarshalAsInt() (int, error)

func (JsonRawMessage) UnmarshalAsString added in v1.0.24

func (message JsonRawMessage) UnmarshalAsString() (string, error)

func (JsonRawMessage) UnmarshalTo added in v1.0.24

func (message JsonRawMessage) UnmarshalTo(dst interface{}) error

type JsonRawMessageMap added in v1.0.24

type JsonRawMessageMap map[string]JsonRawMessage

func (JsonRawMessageMap) Lookup added in v1.0.24

func (m JsonRawMessageMap) Lookup(key string) (JsonRawMessage, bool)

type ListIteratorByReflect added in v1.0.35

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

func NewSliceIteratorByReflectValue added in v1.0.35

func NewSliceIteratorByReflectValue(slice reflect.Value) *ListIteratorByReflect

func (*ListIteratorByReflect) Data added in v1.0.35

func (it *ListIteratorByReflect) Data() any

func (*ListIteratorByReflect) Len added in v1.0.35

func (it *ListIteratorByReflect) Len() int

func (*ListIteratorByReflect) Next added in v1.0.35

func (it *ListIteratorByReflect) Next() bool

type MapIteratorByReflect added in v1.0.35

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

func NewMapIteratorByReflect added in v1.0.35

func NewMapIteratorByReflect(m reflect.Value) *MapIteratorByReflect

func (*MapIteratorByReflect) Data added in v1.0.35

func (*MapIteratorByReflect) Len added in v1.0.35

func (it *MapIteratorByReflect) Len() int

func (*MapIteratorByReflect) Next added in v1.0.35

func (it *MapIteratorByReflect) Next() bool

type NilError added in v1.0.57

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

func NewNilError added in v1.0.57

func NewNilError(name string) NilError

func NewNilErrorFromNames added in v1.0.57

func NewNilErrorFromNames(names ...string) NilError

func (NilError) Error added in v1.0.57

func (err NilError) Error() string

type NotImplementedError

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

func NewNotImplementedError

func NewNotImplementedError(hint string) NotImplementedError

func (NotImplementedError) Error

func (e NotImplementedError) Error() string

type PrivateKeyCipher added in v1.0.6

type PrivateKeyCipher struct {
	PublicKeyCipher
	// contains filtered or unexported fields
}

func NewPrivateKeyCipher added in v1.0.6

func NewPrivateKeyCipher(key *rsa.PrivateKey) *PrivateKeyCipher

func (*PrivateKeyCipher) Decrypt added in v1.0.6

func (c *PrivateKeyCipher) Decrypt(ciphertext []byte) ([]byte, error)

func (*PrivateKeyCipher) DecryptPro added in v1.0.6

func (c *PrivateKeyCipher) DecryptPro(ciphertext []byte, decrypter RsaDecrypter, random io.Reader) ([]byte, error)

func (*PrivateKeyCipher) Sign added in v1.0.6

func (c *PrivateKeyCipher) Sign(data []byte) ([]byte, error)

func (*PrivateKeyCipher) SignPro added in v1.0.6

func (c *PrivateKeyCipher) SignPro(data []byte, signer RsaSigner, random io.Reader, hash crypto.Hash) ([]byte, error)

type PublicKeyCipher added in v1.0.6

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

func NewPublicKeyCipher added in v1.0.6

func NewPublicKeyCipher(key *rsa.PublicKey) *PublicKeyCipher

func (*PublicKeyCipher) Encrypt added in v1.0.6

func (c *PublicKeyCipher) Encrypt(plaintext []byte) ([]byte, error)

func (*PublicKeyCipher) EncryptPro added in v1.0.6

func (c *PublicKeyCipher) EncryptPro(plaintext []byte, encrypter RsaEncrypter, random io.Reader) ([]byte, error)

func (*PublicKeyCipher) Verify added in v1.0.6

func (c *PublicKeyCipher) Verify(data, sign []byte) error

func (*PublicKeyCipher) VerifyPro added in v1.0.6

func (c *PublicKeyCipher) VerifyPro(data, sign []byte, verifier RsaVerifier, hash crypto.Hash) error

type RsaDecrypter added in v1.0.6

type RsaDecrypter = func(io.Reader, *rsa.PrivateKey, []byte) ([]byte, error)

type RsaEncrypter added in v1.0.6

type RsaEncrypter = func(io.Reader, *rsa.PublicKey, []byte) ([]byte, error)

type RsaSigner added in v1.0.6

type RsaSigner = func(io.Reader, *rsa.PrivateKey, crypto.Hash, []byte) ([]byte, error)

type RsaVerifier added in v1.0.6

type RsaVerifier = func(*rsa.PublicKey, crypto.Hash, []byte, []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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