temp

package module
v0.0.0-...-4b5a9e3 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2022 License: BSD-3-Clause Imports: 5 Imported by: 4

README

temp

A package to create temporary files and directories based on the ioutil Go package

This package is now obsolete, the functionality it provides was added to Go std lib in version 1.14

-- import "github.com/zaf/temp"

Usage

func Dir
func Dir(dir, prefix string) (name string, err error)

Dir creates a new temporary directory in the directory dir with a name beginning with prefix and returns the path of the new directory. If dir is the empty string, Dir uses the default directory for temporary files (see os.TempDir). Multiple programs calling Dir simultaneously will not choose the same directory. It is the caller's responsibility to remove the directory when no longer needed.

func File
func File(dir, prefix, extension string) (f *os.File, err error)

File creates a new temporary file with the provided extension in the directory dir with a name beginning with prefix, opens the file for reading and writing, and returns the resulting *os.File. If dir is the empty string, File uses the default directory for temporary files (see os.TempDir). Multiple programs calling File simultaneously will not choose the same file. The caller can use f.Name() to find the pathname of the file. It is the caller's responsibility to remove the file when no longer needed.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir(dir, prefix string) (name string, err error)

Dir creates a new temporary directory in the directory dir with a name beginning with prefix and returns the path of the new directory. If dir is the empty string, Dir uses the default directory for temporary files (see os.TempDir). Multiple programs calling Dir simultaneously will not choose the same directory. It is the caller's responsibility to remove the directory when no longer needed.

func File

func File(dir, prefix, extension string) (f *os.File, err error)

File creates a new temporary file with the provided extension in the directory dir with a name beginning with prefix, opens the file for reading and writing, and returns the resulting *os.File. If dir is the empty string, File uses the default directory for temporary files (see os.TempDir). Multiple programs calling File simultaneously will not choose the same file. The caller can use f.Name() to find the pathname of the file. It is the caller's responsibility to remove the file when no longer needed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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