strz

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 13 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 HexFormat added in v0.0.7

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

HexFormat returns the hex encode format \xXX

func HexFormatToString added in v0.0.7

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

HexFormatToString returns the hex encode format \xXX

func HexParse added in v0.0.7

func HexParse(dst, src []byte) int

HexParse fill dst with the bytes represented by the hex s like \xXX

func HexParseToString added in v0.0.7

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

HexParseToString returns the string represented by the hex s like \xXX

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 OctalFormat added in v0.0.7

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

OctalFormat returns the octal encode format \ooo

func OctalFormatToString added in v0.0.7

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

OctalFormatToString returns the octal encode format \ooo

func OctalParse added in v0.0.7

func OctalParse(dst, src []byte) int

OctalParse fill dst with the bytes represented by the octal s like \ooo

func OctalParseToString added in v0.0.7

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

OctalParseToString returns the string represented by the octal s like \ooo

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 UnicodeFormat added in v0.0.7

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

UnicodeFormat returns the unicode encode format \UXXXXXXXX

func UnicodeFormatToString added in v0.0.7

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

UnicodeFormatToString returns the unicode encode format \UXXXXXXXX

func UnicodeParse added in v0.0.7

func UnicodeParse(dst, src []byte) int

UnicodeParse fill dst with the bytes represented by the unicode s like \UXXXXXXXX

func UnicodeParseToString added in v0.0.7

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

UnicodeParseToString returns the string represented by the unicode s like \UXXXXXXXX

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 UnsafeStrOrBytesToString added in v0.0.7

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

UnsafeStrOrBytesToString converts string or byte slice to string.

func UnsafeString

func UnsafeString(b []byte) string

UnsafeString converts byte slice to string.

func Utf16Format added in v0.0.7

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

Utf16Format returns the utf16 encode format \uXXXX

func Utf16FormatToString added in v0.0.7

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

Utf16FormatToString returns the utf16 encode format \uXXXX

func Utf16Parse added in v0.0.7

func Utf16Parse(dst, src []byte) int

Utf16Parse fill dst with the bytes represented by the utf16 s like \uXXXX

func Utf16ParseToString added in v0.0.7

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

Utf16ParseToString returns the string represented by the utf16 s like \uXXXX

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