utils

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

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

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

type ByteStealer struct {
	Data []byte
}

ByteStealer steal from io.Reader

func (*ByteStealer) Write

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

Directories

Path Synopsis
Package pool contains helpers for pooling structures distinguishable by size.
Package pool contains helpers for pooling structures distinguishable by size.
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