utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2017 License: Apache-2.0 Imports: 12 Imported by: 26

Documentation

Index

Constants

View Source
const (
	UNIX_SOCKET_PREFIX  = "unix://"
	VSOCK_SOCKET_PREFIX = "vsock://"
)

Variables

View Source
var (
	// ErrClosed is returned when Write is called on a closed BytesPipe.
	ErrClosed = errors.New("write to closed BytesPipe")
)

Functions

func DiskId2Name

func DiskId2Name(id int) string

func Mount

func Mount(src, dst string) error

func RandStr added in v0.8.0

func RandStr(strSize int, randType string) string

func SetReadonly added in v0.7.0

func SetReadonly(path string) error

func SocketConnect added in v0.8.0

func SocketConnect(addr string) (net.Conn, error)

func Umount

func Umount(root string)

func UnixSocketConnect

func UnixSocketConnect(addr string) (conn net.Conn, err error)

Types

type BytesPipe added in v1.0.0

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

BytesPipe is io.ReadWriteCloser which works similarly to pipe(queue). All written data may be read at most once. Also, BytesPipe allocates and releases new byte slices to adjust to current needs, so the buffer won't be overgrown after peak loads.

func NewBytesPipe added in v1.0.0

func NewBytesPipe() *BytesPipe

NewBytesPipe creates new BytesPipe, initialized by specified slice. If buf is nil, then it will be initialized with slice which cap is 64. buf will be adjusted in a way that len(buf) == 0, cap(buf) == cap(buf).

func (*BytesPipe) Close added in v1.0.0

func (bp *BytesPipe) Close() error

Close causes further reads from a BytesPipe to return immediately.

func (*BytesPipe) CloseWithError added in v1.0.0

func (bp *BytesPipe) CloseWithError(err error) error

CloseWithError causes further reads from a BytesPipe to return immediately.

func (*BytesPipe) Read added in v1.0.0

func (bp *BytesPipe) Read(p []byte) (n int, err error)

Read reads bytes from BytesPipe. Data could be read only once.

func (*BytesPipe) Write added in v1.0.0

func (bp *BytesPipe) Write(p []byte) (int, error)

Write writes p to BytesPipe. It can allocate new []byte slices in a process of writing.

Jump to

Keyboard shortcuts

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