common

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: GPL-3.0 Imports: 9 Imported by: 30

Documentation

Index

Constants

View Source
const (
	KiB = 1024
	MiB = KiB * 1024
	GiB = MiB * 1024
)
View Source
const (
	Version = "v0.4.5"
)

Variables

This section is empty.

Functions

func GetProgramDir added in v0.1.0

func GetProgramDir() string

func HumanFriendlyTraffic

func HumanFriendlyTraffic(bytes uint64) string

func Must

func Must(err error)

func Must2 added in v0.2.0

func Must2(_ interface{}, err error)

func NewBufioReadWriter added in v0.3.0

func NewBufioReadWriter(rw io.ReadWriter) *bufio.ReadWriter

func ReadByte added in v0.3.0

func ReadByte(r io.Reader) (byte, error)

func RegisterOptionHandler added in v0.0.15

func RegisterOptionHandler(h OptionHandler)

func SHA224String

func SHA224String(password string) string

Types

type Address added in v0.1.4

type Address struct {
	net.Addr

	DomainName  string
	Port        int
	NetworkType string
	net.IP
	AddressType
}

func NewAddress added in v0.1.4

func NewAddress(host string, port int, network string) *Address

func (*Address) Network added in v0.1.4

func (a *Address) Network() string

func (*Address) ResolveIP added in v0.1.4

func (a *Address) ResolveIP(preferV4 bool) (net.IP, error)

func (*Address) String added in v0.1.4

func (a *Address) String() string

type AddressType added in v0.1.4

type AddressType byte
const (
	IPv4       AddressType = 1
	DomainName AddressType = 3
	IPv6       AddressType = 4
)

type Error

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

func NewError

func NewError(info string) *Error

func (*Error) Base

func (e *Error) Base(err error) *Error

func (*Error) Error

func (e *Error) Error() string

type Notifier added in v0.3.0

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

Notifier is a utility for notifying changes. The change producer may notify changes multiple time, and the consumer may get notified asynchronously.

func NewNotifier added in v0.3.0

func NewNotifier() *Notifier

NewNotifier creates a new Notifier.

func (*Notifier) Signal added in v0.3.0

func (n *Notifier) Signal()

Signal signals a change, usually by producer. This method never blocks.

func (*Notifier) Wait added in v0.3.0

func (n *Notifier) Wait() <-chan struct{}

Wait returns a channel for waiting for changes. The returned channel never gets closed.

type OptionHandler added in v0.0.15

type OptionHandler interface {
	Name() string
	Handle() error
	Priority() int
}

func PopOptionHandler added in v0.0.15

func PopOptionHandler() (OptionHandler, error)

type RewindConn added in v0.4.0

type RewindConn struct {
	R *RewindReader
	net.Conn
}

func NewRewindConn added in v0.4.0

func NewRewindConn(conn net.Conn) *RewindConn

func (*RewindConn) Read added in v0.4.0

func (c *RewindConn) Read(p []byte) (int, error)

type RewindReadWriteCloser added in v0.3.0

type RewindReadWriteCloser struct {
	*RewindReader
	// contains filtered or unexported fields
}

func NewRewindReadWriteCloser added in v0.3.0

func NewRewindReadWriteCloser(rwc io.ReadWriteCloser) *RewindReadWriteCloser

func (*RewindReadWriteCloser) Close added in v0.3.0

func (rwc *RewindReadWriteCloser) Close() error

func (*RewindReadWriteCloser) Write added in v0.3.0

func (rwc *RewindReadWriteCloser) Write(p []byte) (int, error)

type RewindReader added in v0.3.0

type RewindReader struct {
	io.Reader
	io.ByteReader
	// contains filtered or unexported fields
}

func NewRewindReader added in v0.3.0

func NewRewindReader(r io.Reader) *RewindReader

func (*RewindReader) Discard added in v0.3.0

func (r *RewindReader) Discard(n int) (int, error)

func (*RewindReader) Read added in v0.3.0

func (r *RewindReader) Read(p []byte) (int, error)

func (*RewindReader) ReadByte added in v0.3.0

func (r *RewindReader) ReadByte() (byte, error)

func (*RewindReader) Rewind added in v0.3.0

func (r *RewindReader) Rewind()

func (*RewindReader) SetBufferSize added in v0.3.0

func (r *RewindReader) SetBufferSize(size int)

func (*RewindReader) StopBuffering added in v0.3.0

func (r *RewindReader) StopBuffering()

type Runnable

type Runnable interface {
	Run() error
	Close() error
}

Jump to

Keyboard shortcuts

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