...

Package temp

import "k8s.io/utils/temp"
Overview
Index
Subdirectories

Overview ▾

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

type Dir

Dir is wrapping an temporary directory on disk.

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

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

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

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
}

Subdirectories

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