helpers

package module
v0.0.0-...-e696fad Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: GPL-3.0 Imports: 17 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BidirectCopy

func BidirectCopy(left io.ReadWriteCloser, right io.ReadWriteCloser) (int, int, error)

BidirectCopy is a helper which spawns two goroutines. Each goroutine copies data from left to right and right to left respectively.

func ByteCountIEC

func ByteCountIEC(b int) string

func Checksum

func Checksum(r io.Reader) ([]byte, error)

func ConfigPath

func ConfigPath(name string) string

func Confirm

func Confirm(message string) bool

func CreateIfNotExists

func CreateIfNotExists(path string, perm os.FileMode) error

func CreateMemPool

func CreateMemPool() sync.Pool

func GetEnvBool

func GetEnvBool(name string) bool

func GetSlice

func GetSlice(pool *sync.Pool, size int) []byte

func GetTermSize

func GetTermSize(fd int) (width, height int, err error)

func MkdirIfNotExists

func MkdirIfNotExists(path string, perm os.FileMode) error

func RandStr

func RandStr(length int) string

TODO: Remove this

func RandomBytes

func RandomBytes(n int) ([]byte, error)

RandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func RandomString

func RandomString(n int) (string, error)

RandomString returns a securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func RandomStringURLSafe

func RandomStringURLSafe(n int) (string, error)

RandomStringURLSafe returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func RecvJSON

func RecvJSON(r *http.Request, data interface{}) error

func SendJSON

func SendJSON(w http.ResponseWriter, jsonObject interface{}) error

func SendJSONError

func SendJSONError(w http.ResponseWriter, err string, code int)

Types

type Broadcaster

type Broadcaster struct {
	InCh    chan []byte
	OutChs  []chan []byte
	MemPool *sync.Pool
	WG      *sync.WaitGroup
}

func (*Broadcaster) Serve

func (bc *Broadcaster) Serve()

Jump to

Keyboard shortcuts

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