tempdir

package
v0.0.0-...-f58e8bd Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package tempdir provides helpers for temporary directories.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidFuncType indicates that an invalid type was provided.
	ErrInvalidFuncType = errors.New("invalid func type")
)

Functions

func With

func With[T Func](fn T) (err error)

With creates a new Dir, and calls Dir.With(fn), returning any errors.

Types

type Dir

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

A Dir represents a temporary directory. Dir must be constructed with New or NewWithBase.

func New

func New() (*Dir, error)

New creates a new Dir using the system's default temporary directory as the base for this temporary directory.

func NewWithBase

func NewWithBase(dir string) (*Dir, error)

NewWithBase creates a new Dir using the provided dir as the base for this temporary directory.

func (*Dir) Close

func (d *Dir) Close() error

Close cleans up d's temporary directory. No further calls to d.With will be executed.

func (*Dir) With

func (d *Dir) With(fn any) error

With changes the working directory to d's temporary directory and invokes fn, returning any error.

type Func

type Func interface {
	PathFunc | PathErrorFunc
}

Func constrains the types of functions allowed by With (and opaqely, Dir.With).

type PathErrorFunc

type PathErrorFunc = func(path string) error

A PathErrorFunc is a function that accepts a temporary path and returns an error.

type PathFunc

type PathFunc = func(path string)

A PathFunc is a function that accepts a temporary path.

Jump to

Keyboard shortcuts

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