temp

package
v0.0.0-...-0849a56 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

README

Temp

This package provides an interface to create temporary directories. It also provides a FakeDir implementation to replace in tests.

Documentation

Overview

Package temp provides an interface to handle temporary files and directories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dir

type Dir struct {
	// Name is the name (full path) of the created directory.
	Name string
}

Dir is wrapping an temporary directory on disk.

func CreateTempDir

func CreateTempDir(prefix string) (*Dir, error)

CreateTempDir returns a new Directory wrapping a temporary directory on disk.

func (*Dir) Delete

func (d *Dir) Delete() error

Delete the underlying directory, and all of its content.

func (*Dir) NewFile

func (d *Dir) NewFile(name string) (io.WriteCloser, error)

NewFile creates a new file in the specified directory.

type Directory

type Directory interface {
	// NewFile creates a new file in that directory. Calling NewFile
	// with the same filename twice will result in an error.
	NewFile(name string) (io.WriteCloser, error)
	// Delete removes the directory and its content.
	Delete() error
}

Directory is an interface to a temporary directory, in which you can create new files.

Directories

Path Synopsis
Package temptest provides utilities for testing temp files/directories testing.
Package temptest provides utilities for testing temp files/directories testing.

Jump to

Keyboard shortcuts

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