util

package
v0.10.5 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeNetstring

func DecodeNetstring(netstr []byte) (string, error)

func EncodeNetstring

func EncodeNetstring(str string) []byte

func RandomString32

func RandomString32() (string, error)

24 bytes (192 bits) of entropy, base64 encoded

func RemoveSocket

func RemoveSocket(path string) error

Types

type Alerter

type Alerter interface {
	Alertf(format string, a ...interface{})
	Successf(format string, a ...interface{})
}

type ChanLogger

type ChanLogger chan string

func (ChanLogger) Printf

func (c ChanLogger) Printf(format string, v ...interface{}) error

type Err

type Err struct {
	Last error // is an interface, but its zero type is nil
}

func (*Err) Alertf

func (e *Err) Alertf(format string, a ...interface{})

func (*Err) Successf

func (e *Err) Successf(string, ...interface{})

type FileLogger

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

Logs into a file. Timestamps are in UTC.

func NewFileLogger

func NewFileLogger(filepath string) (*FileLogger, error)

func (*FileLogger) Close

func (l *FileLogger) Close() error

func (*FileLogger) Printf

func (l *FileLogger) Printf(format string, v ...interface{}) error

log.Printf drops the returned error, we don't. In case of a write error, we reopen the file and try again.

type Logger

type Logger interface {
	Printf(format string, v ...interface{}) error
}

Jump to

Keyboard shortcuts

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