fileutils

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExistsAndIsDirectory

func ExistsAndIsDirectory(path string) (exists, isDir bool, err error)

func ReadOrPanic

func ReadOrPanic(p string) []byte

ReadOrPanic reads the entire file at the provided path or panics if it is not possible.

func SafeReadFile

func SafeReadFile(filePath string, perm os.FileMode) ([]byte, error)

SafeReadFile reads the file at the provided path into a byte slice.

func SafeReadJSON

func SafeReadJSON(filePath string, targetPointer any, perm os.FileMode) (jsonAvailable bool, err error)

SafeReadJSON reads the JSON file at the path into the targetPointer. Returns true if the file exists or an error if an error occurred.

func SafeReadYAML

func SafeReadYAML(filePath string, targetPointer any, perm os.FileMode) (yamlAvailable bool, err error)

SafeReadYAML reads the YAML file at the path into the targetPointer. Returns true if the file exists or an error if an error occurred.

func SafeWriteJson

func SafeWriteJson[T any](filePath string, targetPointer *T) error

SafeWriteJson writes the provided object to a JSON file at the provided path. The function makes sure any changes are flushed to the disk before returning.

Types

This section is empty.

Jump to

Keyboard shortcuts

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