sandbox

package module
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2019 License: BSD-2-Clause-Views Imports: 5 Imported by: 1

README

sandbox

GitHub release GitHub issues Go Version Build Status GoDoc SemVer License Go Report Card

Go library to create & manage lightweight sandboxes (like temporary files).

Requirements

  • Go >= 1.10

Installation

This is a pure library, there is no associated command..

Installation is like many Go libraries with a simple

go get github.com/keltia/sandbox

sandbox also has vgo support & metadata (see the articles on vgo). It respects the Semantic Versioning principle with tagged releases.

You can thus use

vgo install github.com/keltia/sandbox

to install the library.

API Usage

snd, err := sandbox.New("foo")
if err != nil {
    log.Fatalf("can not create sandbox: %v", err)
}
defer snd.Cleanup()

err := snd.Enter()
fmt.Println("Inside sandbox")
err := snd.Exit()

You can also sandbox a single func with Run():

err := snd.Run(func() error {
    fmt.Printf("I am in %d", snd.Cwd())
})

License

This is under the 2-Clause BSD license, see LICENSE.md.

History

I originally wrote this code for various projects of mine and have re-used it enough time to think about putting it into its own module.

Contributing

Please see CONTRIBUTING.md for some simple rules.

Documentation

Index

Constants

View Source
const (
	// MyVersion is the SemVer version
	MyVersion = "0.9.3"

	// MyName is for when we need it
	MyName = "sandbox"
)

Variables

This section is empty.

Functions

func Version added in v0.9.0

func Version() string

Types

type Dir

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

func New

func New(tag string) (*Dir, error)

func (*Dir) Cleanup

func (s *Dir) Cleanup() error

func (*Dir) Cwd

func (s *Dir) Cwd() string

func (*Dir) Enter

func (s *Dir) Enter() error

func (*Dir) Exit

func (s *Dir) Exit() error

func (*Dir) Run added in v0.9.2

func (s *Dir) Run(f func() error) error

Jump to

Keyboard shortcuts

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