util

package
v0.0.0-...-84ddfae Latest Latest
Warning

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

Go to latest
Published: May 7, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrReadAfterClose = errors.New("cannot Read from closed *TestReadCloser")

ErrReadAfterClose is a sentinel error returned by (*TestReadCloser).Read.

Functions

func AddInt64

func AddInt64(x, y int64) (sum int64, ok bool)

AddInt64 adds two signed 64-bit integers with overflow detection.

func FormatIth

func FormatIth(i int) string

func PathIsLexicalDescendant

func PathIsLexicalDescendant(path, maybeAncestorPath string) bool

PathIsLexicalDescendant return true if and only if path == maybeAncestorPath or strings.HasPrefix(path + "/", maybeAncestorPath + "/")

func ReadJSON200Response

func ReadJSON200Response(resp *http.Response, respBody any, disallowUnknownFields bool) error

func SumInt64

func SumInt64(x ...int64) (sum int64, ok bool)

SumInt64 sums multiple signed 64-bit integers with overflow detection.

func UnmarshalJSON

func UnmarshalJSON(reader io.Reader, v any, disallowUnknownFields bool) error

Types

type ConcatReader

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

func NewConcatReader

func NewConcatReader(prefix []byte, r io.Reader, suffix []byte, close func() error) *ConcatReader

func (*ConcatReader) Close

func (c *ConcatReader) Close() error

func (*ConcatReader) Read

func (c *ConcatReader) Read(p []byte) (n int, err error)

type Environ

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

func NewEnviron

func NewEnviron(environ []string, isCaseSensitive bool) *Environ

func (*Environ) Copy

func (e *Environ) Copy() *Environ

func (*Environ) ForEach

func (e *Environ) ForEach(callback func(name, value string) bool)

func (*Environ) Get

func (e *Environ) Get(name string) string

func (*Environ) GetSlice

func (e *Environ) GetSlice() []string

func (*Environ) Lookup

func (e *Environ) Lookup(name string) (value string, ok bool)

func (*Environ) Set

func (e *Environ) Set(name, value string)

func (*Environ) Unset

func (e *Environ) Unset(name string)

type TestReadCloser

type TestReadCloser struct {
	CloseCount int
	CloseErr   error

	// ReadData is data returned by Read.
	ReadData []byte
	// ReadErr is an error to return from Read after ReadData is consumed.
	ReadErr error
}

func (*TestReadCloser) Close

func (t *TestReadCloser) Close() error

func (*TestReadCloser) Read

func (t *TestReadCloser) Read(p []byte) (n int, err error)

type TestWriter

type TestWriter struct {
	Buffer bytes.Buffer
	// contains filtered or unexported fields
}

func NewTestWriter

func NewTestWriter(err error, errAfter int) (*TestWriter, error)

func (*TestWriter) Write

func (t *TestWriter) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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