Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

exit

v1.28.0
go.uber.org/zap/internal/exit

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

7 matches

Top ↑

Package exit provides stubs so that unit tests can exercise code that calls os.Exit(1).

Functions

With

func With(code int)

With terminates the process by calling os.Exit(code). If the package is stubbed, it instead records a call in the testing spy.

Types

StubbedExit

type StubbedExit struct {
	Exited bool
	Code   int
	// contains filtered or unexported fields
}

A StubbedExit is a testing fake for os.Exit.

Stub

func Stub() *StubbedExit

Stub substitutes a fake for the call to os.Exit(1).

WithStub

func WithStub(f func()) *StubbedExit

WithStub runs the supplied function with Exit stubbed. It returns the stub used, so that users can test whether the process would have crashed.

StubbedExit.Unstub

func (se *StubbedExit) Unstub()

Unstub restores the previous exit function.

Dependency graph