baseutils

package
v1.0.48 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

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 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 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 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

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 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 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