files

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 8 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertJSONArrayToYAML

func ConvertJSONArrayToYAML(jsonContent string) (string, error)

func ConvertJSONMapToYAML

func ConvertJSONMapToYAML(jsonContent string) (string, error)

func ConvertYAMLArrayToJSON

func ConvertYAMLArrayToJSON(yamlContent string) (string, error)

func ConvertYAMLMapToJSON

func ConvertYAMLMapToJSON(yamlContent string) (string, error)

func CopyReaderToTemporaryFile added in v0.4.36

func CopyReaderToTemporaryFile(prefix string, name string, r io.Reader) (string, error)

CopyReaderToTemporaryFile creates a temporary file with a given prefix, name and copies data from a reader into it.

In the event of any errors during the file creation or data copying, it cleans up by deleting the file and returns the error.

Returns the path to the temporary file on success.

func GarbageCollectTemporaryFiles added in v0.4.25

func GarbageCollectTemporaryFiles(tempDir string, mask string, n int) ([]string, error)

GarbageCollectTemporaryFiles deletes the oldest files in a directory based on a given mask, leaving only 'n' newest files. It returns a slice of paths of the deleted files. It requires read and write permissions on the directory. If it encounters a file that it cannot delete, it will stop and return the files it has deleted so far along with the error.

func LoadJSONFile

func LoadJSONFile(path string, target interface{}) error

func LoadYAMLFile

func LoadYAMLFile(path string, target interface{}) error

func WriteTemporaryFile added in v0.4.36

func WriteTemporaryFile(prefix string, name string, body []byte) (string, error)

WriteTemporaryFile creates a temporary file with a given prefix, name and writes data into it.

In the event of any errors, it cleans up by deleting the file and returns the error.

Returns: Path of the temp file and error if any.

Types

This section is empty.

Jump to

Keyboard shortcuts

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