file

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cd

func Cd(dir string)

Cd changes the current working directory to the provided relative or absolute directory

func Contains

func Contains(file, substr string) bool

Contains indicates the given file contains the provided substring

func Cwd

func Cwd() string

Cwd returns the current working directory

func Delete

func Delete(path string)

Delete removes the given file or directory, first verifying it is a subdirectory of RootDir

func EnsureDir

func EnsureDir(dir string)

EnsureDir checks if the directory exists. create if not, including any subdirectories needed

func Exists

func Exists(file string) bool

Exists indicates a file of any type (regular, directory, symlink, etc.) exists and is readable

func Find

func Find(glob string) string

Find finds the first matching file given a glob expression in the CWD

func FindAll

func FindAll(glob string) []string

FindAll finds all matching files given a glob expression

func FindParent

func FindParent(dir string, glob string) string

FindParent finds the first matching file in the specified directory or any parent directory

func Fingerprint

func Fingerprint(globs ...string) string

Fingerprint hashes all files and provides a stable hash of all the contents

func InDir

func InDir(dir string, run func())

InDir executes the given function in the provided directory, returning to the current working directory upon completion

func InTempDir

func InTempDir(fn func())

InTempDir executes with the current working directory in a new temporary directory, restoring cwd and removing all contents of the temp directory upon completion

func IsDir

func IsDir(dir string) bool

IsDir indicates the provided directory exists and is a directory

func IsRegular

func IsRegular(name string) bool

IsRegular indicates the provided file exists and is a regular file, not a directory or symlink

func JoinPaths

func JoinPaths(paths ...string) string

JoinPaths joins paths together using an OS-appropriate separator

func LogWorkdir

func LogWorkdir()

func Ls

func Ls(dir string) string

func Read

func Read(file string) string

Read reads the file and returns the contents as a string

func Require

func Require(file string)

Require panics if the provided file does not exist

func Sha256Hash

func Sha256Hash(file string) string

func WithTempDir

func WithTempDir(fn func(dir string))

WithTempDir creates a temporary directory, provided for the duration of the function call, removing all contents upon completion

func Write

func Write(path, contents string)

Write writes the provided contents to a file

Types

This section is empty.

Jump to

Keyboard shortcuts

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