utils

package
v1.6.7 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: Apache-2.0 Imports: 5 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(err error, msg ...interface{})

Assert if nil != err

func AssertBytes

func AssertBytes(b []byte, err error) []byte

AssertBytes check error

func AssertIf

func AssertIf(exp bool, msg string, args ...interface{})

AssertIf exp

func AssertLength

func AssertLength(n int, err error) int

AssertLength check error

func AssertLong

func AssertLong(n int64, err error) int64

AssertLong check error

func CountOf

func CountOf(buffs [][]byte) (n int64)

CountOf count bytes of buffs

func MustToBytes

func MustToBytes(message interface{}) []byte

MustToBytes any error to panic

func MustToReader

func MustToReader(message interface{}) io.Reader

MustToReader any error to panic

func StealBytes added in v1.4.0

func StealBytes(reader io.WriterTo) ([]byte, error)

func ToBytes

func ToBytes(message interface{}) ([]byte, error)

ToBytes unwrap a message to []byte

func ToReader

func ToReader(message interface{}) (io.Reader, error)

ToReader wrap message to io.Reader

Types

type ByteReader

type ByteReader interface {
	io.Reader
	io.ByteReader
}

ByteReader defines byte reader

func NewByteReader

func NewByteReader(r io.Reader) ByteReader

NewByteReader create a ByteReader from io.Reader

type ByteStealer added in v1.4.0

type ByteStealer struct {
	Data []byte
}

ByteStealer steal from io.Reader

func (*ByteStealer) Write added in v1.4.0

func (s *ByteStealer) Write(p []byte) (n int, err error)

Directories

Path Synopsis
pbytes
Package pbytes contains tools for pooling byte pool.
Package pbytes contains tools for pooling byte pool.

Jump to

Keyboard shortcuts

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