byteseq

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2025 License: MIT Imports: 1 Imported by: 8 modules, 21 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Byte Sequence

Generic type and conversion functions for string and byte slices.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func B2Q

func B2Q[T Q](p []byte) T

B2Q is a shorthand alias of BytesToSequence().

func BytesToSequence

func BytesToSequence[T Byteseq](p []byte) T

BytesToSequence makes fast conversion of bytes to sequence.

func Q2B

func Q2B[T Q](x T) []byte

Q2B is a shorthand alias of SequenceToBytes().

func Q2S

func Q2S[T Q](x T) string

Q2S is a shorthand alias of SequenceToString().

func S2Q

func S2Q[T Q](s string) T

S2Q is a shorthand alias of StringToSequence().

func SequenceToBytes

func SequenceToBytes[T Byteseq](x T) []byte

SequenceToBytes makes fast conversion of sequence to bytes.

func SequenceToString

func SequenceToString[T Byteseq](x T) string

SequenceToString makes fast conversion of sequence to string.

func StringToSequence

func StringToSequence[T Byteseq](s string) T

StringToSequence makes fast conversion of string to sequence.

func ToBytes added in v1.0.1

func ToBytes[T Byteseq](x T) (p []byte, ok bool)

ToBytes tries to convert x to bytes.

func ToString added in v1.0.1

func ToString[T Byteseq](x T) (s string, ok bool)

ToString tries to convert x to string.

Types

type Byteseq

type Byteseq interface {
	~string | ~[]byte
}

Byteseq represents generic byte sequence types.

type Q added in v1.0.1

type Q = Byteseq

Q is a shorthand alias of Byteseq.

Jump to

Keyboard shortcuts

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