helper

package
v0.0.0-...-767fa57 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2023 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BreakRead

func BreakRead(s ReadDeadlineSetter) error

func BreakReadWrite

func BreakReadWrite(s DeadlineSetter) error

func BreakWrite

func BreakWrite(s WriteDeadlineSetter) error

func Clone

func Clone[T any](s []T) []T

func Decode

func Decode(buf []byte, out any) error

func DecodeAs

func DecodeAs[T any](buf []byte) (T, error)

func Encode

func Encode(in any) ([]byte, error)

func GetCancelStdin

func GetCancelStdin() (reader io.Reader, cancel func(), stdin *os.File)

func Hash256

func Hash256(data []byte) []byte

func HashSalt256

func HashSalt256(data []byte, salt []byte) []byte

func MustEncode

func MustEncode(in any) []byte

func NewCtrlPacket

func NewCtrlPacket(data []byte) *pb.Packet

func NewDataPacket

func NewDataPacket(data []byte) *pb.Packet

func NewErrorPacket

func NewErrorPacket(s string) *pb.Packet

func NewReadWriterCloser

func NewReadWriterCloser(r io.Reader, w io.Writer, c io.Closer) io.ReadWriteCloser

func PromptHiddenInput

func PromptHiddenInput(message string) (input []byte, err error)

func RefreshRead

func RefreshRead(s ReadDeadlineSetter) error

func RefreshReadWrite

func RefreshReadWrite(s DeadlineSetter) error

func RefreshWrite

func RefreshWrite(s WriteDeadlineSetter) error

func SplitEndpoint

func SplitEndpoint(endpoint string) (network string, address string)

Types

type DeadlineSetter

type DeadlineSetter interface {
	SetDeadline(t time.Time) error
}

type Gate

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

func NewGate

func NewGate(ctx context.Context, max int) *Gate

func (*Gate) Enter

func (g *Gate) Enter() (entered bool)

func (*Gate) Leave

func (g *Gate) Leave()

type ReadDeadlineSetter

type ReadDeadlineSetter interface {
	SetReadDeadline(t time.Time) error
}

type ReadWriteCloser

type ReadWriteCloser struct {
	io.Reader
	io.Writer
	io.Closer
}

type Set

type Set[T comparable] struct {
	// contains filtered or unexported fields
}

func NewSet

func NewSet[T comparable](values ...T) *Set[T]

func (*Set[T]) Add

func (s *Set[T]) Add(values ...T)

func (*Set[T]) Has

func (s *Set[T]) Has(values ...T) (exists bool)

func (*Set[T]) Len

func (s *Set[T]) Len() int

func (*Set[T]) Remove

func (s *Set[T]) Remove(values ...T)

func (*Set[T]) Values

func (s *Set[T]) Values() (values []T)

type WaitGroup

type WaitGroup struct {
	DoneFn func(string)

	DefaultName string
	// contains filtered or unexported fields
}

func NewWaitGroup

func NewWaitGroup() *WaitGroup

func (*WaitGroup) ActiveNames

func (wg *WaitGroup) ActiveNames() []string

func (*WaitGroup) Add

func (wg *WaitGroup) Add(n int)

func (*WaitGroup) AddName

func (wg *WaitGroup) AddName(name string, n int)

func (*WaitGroup) Done

func (wg *WaitGroup) Done()

func (*WaitGroup) DoneName

func (wg *WaitGroup) DoneName(name string)

func (*WaitGroup) Go

func (wg *WaitGroup) Go(f func())

func (*WaitGroup) GoName

func (wg *WaitGroup) GoName(name string, f func())

func (*WaitGroup) Wait

func (wg *WaitGroup) Wait()

type WriteDeadlineSetter

type WriteDeadlineSetter interface {
	SetWriteDeadline(t time.Time) error
}

Jump to

Keyboard shortcuts

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