utils

package
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HTTPClient = &http.Client{
	Transport: netTransport,
	Timeout:   2 * time.Second,
}

Functions

func Alias

func Alias(prefix, name string, cmd oodle.Command) oodle.Command

Alias returns a new command with replaced prefix, name and usage

func Contains added in v1.7.0

func Contains(s []string, e string) bool

func FakeBrowser added in v1.12.1

func FakeBrowser(req *http.Request)

func FakePOST added in v1.12.1

func FakePOST(url string, body io.Reader) ([]byte, error)

func FmtDur

func FmtDur(d time.Duration) string

func FmtTime

func FmtTime(t time.Time) string

func GetJSON added in v1.12.1

func GetJSON(url string, data interface{}) error

func LimitBody added in v1.12.1

func LimitBody(rc io.ReadCloser, megaBytes int64) io.ReadCloser

LimitBody is similar to io.LimitReader but it takes an io.ReadCloser and accepts the limit in megabytes

func Min added in v1.14.0

func Min(x, y int) int

func ParseDuration added in v1.4.0

func ParseDuration(s string) (time.Duration, error)

Note: fork of time.ParseDuration which supports more units ParseDuration parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".

func RunCases

func RunCases(t *testing.T, cmd oodle.Command, tests []TestCase)

RunCases runs given tests on an oodle.Command

func Summarize added in v1.4.1

func Summarize(text string) (summarized string)

Types

type LimitedReader added in v1.12.1

type LimitedReader struct {
	R io.ReadCloser // underlying reader/closer
	N int64         // max bytes remaining
}

func (*LimitedReader) Close added in v1.12.1

func (l *LimitedReader) Close() error

func (*LimitedReader) Read added in v1.12.1

func (l *LimitedReader) Read(p []byte) (n int, err error)

type TestCase

type TestCase struct {
	Nick  string
	Args  []string
	Reply string
	Err   error
}

TestCase represents a test case for an oodle.Command

Jump to

Keyboard shortcuts

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