fileio

package
v0.0.0-...-f250034 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package fileio provides high-level file operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFiles

func CopyFiles(pattern string, dstDir string, perm fs.FileMode) error

CopyFile copies all files matching the pattern to the destination directory. Does not overwrite existing file.

func Exists

func Exists(path string) bool

Exists checks if the specified path exists.

func JoinDir

func JoinDir(dir string, name string) (string, error)

JoinDir joins a directory path with a relative file path, making sure that the resulting path is still inside the directory. Returns an error otherwise.

func MkdirTemp

func MkdirTemp(perm fs.FileMode) (string, error)

MkdirTemp creates a new temporary directory with given permissions and returns the pathname of the new directory.

func ReadJson

func ReadJson[T any](path string) (T, error)

ReadJson reads the file and decodes it from JSON.

func WriteFile

func WriteFile(path, content string, perm fs.FileMode) (err error)

WriteFile writes the file to disk. The content can be text or binary (encoded as a data URL), e.g. data:application/octet-stream;base64,MTIz

Types

This section is empty.

Jump to

Keyboard shortcuts

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