must

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package must contains simple functions that panic on errors.

It should only be used in tests and rare places where errors are provably impossible.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chdir

func Chdir(dir string)

Chdir wraps os.Chdir.

func CreateEmpty

func CreateEmpty(names ...string)

CreateEmpty creates empty file, after creating all ancestor directories that don't exist.

func MkdirAll

func MkdirAll(names ...string)

MkdirAll calls os.MkdirAll for each argument.

func OK

func OK(err error)

OK panics if the error value is not nil. It is intended for use with functions that return just an error.

func OK1

func OK1[T any](v T, err error) T

OK1 panics if the error value is not nil. It is intended for use with functions that return one value and an error.

func OK2

func OK2[T1, T2 any](v1 T1, v2 T2, err error) (T1, T2)

OK2 panics if the error value is not nil. It is intended for use with functions that return two values and an error.

func Pipe

func Pipe() (*os.File, *os.File)

Pipe wraps os.Pipe.

func ReadAllAndClose

func ReadAllAndClose(r io.ReadCloser) []byte

ReadAll wraps io.ReadAll and io.Closer.Close.

func ReadFile

func ReadFile(fname string) []byte

ReadFile wraps os.ReadFile.

func ReadFileString

func ReadFileString(fname string) string

ReadFileString converts the result of ReadFile to a string.

func WriteFile

func WriteFile(filename, data string)

WriteFile writes data to a file, after creating all ancestor directories that don't exist.

Types

This section is empty.

Jump to

Keyboard shortcuts

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