Help us shape the future of Go! Take the 2026 Go Developer Survey

context

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists(opt *option.Option) bool

Exists returns true if the supplied (merged) Option already contains a context.

TODO(jaypipes): We can get rid of this when we combine the option and context packages, which will make it easier to detect the presence of a pre-setup Context.

func WithContext

func WithContext(ctx *Context) *option.Option

WithContext returns an option.Option that contains a pre-existing Context struct. This is useful for some internal code that sets up snapshots.

Types

type Context

type Context struct {
	Chroot            string
	EnableTools       bool
	SnapshotPath      string
	SnapshotRoot      string
	SnapshotExclusive bool
	PathOverrides     option.PathOverrides
	// contains filtered or unexported fields
}

Context contains the merged set of configuration switches that act as an execution context when calling internal discovery methods

func FromEnv

func FromEnv() *Context

FromEnv returns a Context that has been populated from the environs or default options values

func New

func New(opts ...*option.Option) *Context

New returns a Context struct pointer that has had various options set on it

func (*Context) Do

func (ctx *Context) Do(fn func() error) error

Do wraps a Setup/Teardown pair around the given function

func (*Context) Setup

func (ctx *Context) Setup() error

Setup prepares the extra optional data a Context may use. `Context`s are ready to use once returned by `New`. Optional features, like snapshot unpacking, may require extra steps. Run `Setup` to perform them. You should call `Setup` just once. It is safe to call `Setup` if you don't make use of optional extra features - `Setup` will do nothing.

func (*Context) Teardown

func (ctx *Context) Teardown() error

Teardown releases any resource acquired by Setup. You should always call `Teardown` if you called `Setup` to free any resources acquired by `Setup`. Check `Do` for more automated management.

func (*Context) Warn

func (ctx *Context) Warn(msg string, args ...interface{})

Jump to

Keyboard shortcuts

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