strz

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode[T typez.StrOrBytes](s T, enc *base64.Encoding) ([]byte, error)

Base64Decode returns the bytes represented by the base64 s

func Base64DecodeToString

func Base64DecodeToString[T typez.StrOrBytes](s T, enc *base64.Encoding) (string, error)

Base64DecodeToString returns the string represented by the base64 s

func Base64Encode

func Base64Encode[T typez.StrOrBytes](s T, enc *base64.Encoding) []byte

Base64Encode returns the base64 encoding of s

func Base64EncodeToString

func Base64EncodeToString[T typez.StrOrBytes](s T, enc *base64.Encoding) string

Base64EncodeToString returns the base64 encoding of s

func CamelCaseToSnake

func CamelCaseToSnake(str string) string

CamelCaseToSnake converts a camel case string to a snake case string

func HexDecode

func HexDecode[T typez.StrOrBytes](s T) ([]byte, error)

HexDecode returns the bytes represented by the hexadecimal s

func HexDecodeInPlace

func HexDecodeInPlace(b []byte) (int, error)

HexDecodeInPlace decodes the hexadecimal s in place

func HexDecodeToString

func HexDecodeToString[T typez.StrOrBytes](s T) (string, error)

HexDecodeToString returns the string represented by the hexadecimal s

func HexEncode

func HexEncode[T typez.StrOrBytes](s T) []byte

HexEncode returns the hex encoding of s

func HexEncodeToString

func HexEncodeToString[T typez.StrOrBytes](s T) string

HexEncodeToString returns the hex encoding of s

func IPv4ToLong

func IPv4ToLong(ip string) uint32

IPv4ToLong converts an IPv4 address to a uint32

func LcFirst

func LcFirst(s string) string

LcFirst returns a string with the first character converted to lowercase

func Len

func Len(s string) int

Len returns the number of runes in a string

func LongToIPv4

func LongToIPv4(long uint32) string

LongToIPv4 converts a uint32 to an IPv4 address

func Mask

func Mask(str, mask string, start, end int) string

Mask returns a string with the first `start` and last `end` characters

func OctalDecode

func OctalDecode[T typez.StrOrBytes](s T) []byte

OctalDecode returns the bytes represented by the octal s

func OctalDecodeInPlace

func OctalDecodeInPlace(b []byte) int

OctalDecodeInPlace decodes the octal s in place

func OctalDecodeToString

func OctalDecodeToString[T typez.StrOrBytes](s T) string

OctalDecodeToString returns the string represented by the octal s

func OctalEncode

func OctalEncode[T typez.StrOrBytes](s T) []byte

OctalEncode returns the octal encoding of s

func OctalEncodeToString

func OctalEncodeToString[T typez.StrOrBytes](s T) string

OctalEncodeToString returns the octal encoding of s

func ParseUint

func ParseUint[T typez.StrOrBytes](s T, base int, bitSize int) (uint64, error)

ParseUint is like ParseInt but for unsigned numbers.

A sign prefix is not permitted.

func RemoveRunes

func RemoveRunes(s string, shouldRemove func(rune) bool) string

RemoveRunes removes the specified characters from the string

func Rev

func Rev(s string) string

Rev returns a string with the characters in reverse order

func SnakeToCamelCase

func SnakeToCamelCase(str string, firstUp bool) string

SnakeToCamelCase converts a snake case string to a camel case string

func Sub

func Sub(s string, start, length int) string

Sub return a substring of a string by start position and length. If length is -1, the substring starting from start position to the end of the string will be returned.

func SubByDisplay

func SubByDisplay(s string, length int) string

SubByDisplay returns a substring of a string by display width

func ToString

func ToString(value any) string

ToString converts a value to a string

func UcFirst

func UcFirst(s string) string

UcFirst returns a string with the first character converted to uppercase

func UnsafeBytes

func UnsafeBytes(s string) []byte

UnsafeBytes converts string to byte slice. maybe safe risk

func UnsafeStrOrBytesToBytes

func UnsafeStrOrBytesToBytes[T typez.StrOrBytes](s T) []byte

UnsafeStrOrBytesToBytes converts string or byte slice to byte slice. maybe safe risk

func UnsafeString

func UnsafeString(b []byte) string

UnsafeString converts byte slice to string.

Types

type KeyGenerator

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

KeyGenerator is a key generator.

func NewKeyGenerator

func NewKeyGenerator(delimiter string, parts ...string) KeyGenerator

NewKeyGenerator creates a new key generator.

func (KeyGenerator) Generate

func (k KeyGenerator) Generate(parts ...string) string

Generate generates a key.

func (KeyGenerator) Spread

func (k KeyGenerator) Spread() []string

Spread returns the spread of the key.

func (KeyGenerator) With

func (k KeyGenerator) With(parts ...string) KeyGenerator

With returns a new key generator with the given parts.

type Reader

type Reader[T typez.StrOrBytes] struct {
	// contains filtered or unexported fields
}

Reader is a wrapper around a string or byte slice that implements io.Reader,

func NewReader

func NewReader[T typez.StrOrBytes](s T) *Reader[T]

NewReader returns a new Reader reading from s.

func (*Reader[T]) Bytes

func (r *Reader[T]) Bytes() []byte

Bytes returns a slice of the underlying string or byte slice.

func (*Reader[T]) Close

func (r *Reader[T]) Close() error

Close closes the Reader, preventing further reading.

func (*Reader[T]) Len

func (r *Reader[T]) Len() int

Len returns the number of bytes of the unread portion of the

func (*Reader[T]) Read

func (r *Reader[T]) Read(p []byte) (n int, err error)

Reset resets the Reader to be reading from s.

func (*Reader[T]) ReadAt

func (r *Reader[T]) ReadAt(b []byte, off int64) (n int, err error)

ReadAt reads len(p) bytes from the Reader starting at byte offset off.

func (*Reader[T]) ReadByte

func (r *Reader[T]) ReadByte() (byte, error)

ReadByte reads and returns the next byte from the Reader.

func (*Reader[T]) Reset

func (r *Reader[T]) Reset(s T)

Reset resets the Reader to read from s.

func (*Reader[T]) Seek

func (r *Reader[T]) Seek(offset int64, whence int) (int64, error)

Seek implements io.Seeker.

func (*Reader[T]) Size

func (r *Reader[T]) Size() int64

Size returns the original length of the underlying string or byte slice.

func (*Reader[T]) UnreadByte

func (r *Reader[T]) UnreadByte() error

UnreadByte unreads the last byte. Only the most recently read byte can be unread.

func (*Reader[T]) WriteTo

func (r *Reader[T]) WriteTo(w io.Writer) (n int64, err error)

WriteTo implements io.WriterTo.

Jump to

Keyboard shortcuts

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