fs

package
v0.0.0-...-7fb663c Latest Latest
Warning

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

Go to latest
Published: May 3, 2020 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package fs provides a uniform api for filesystem-related functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDirectory

func CreateDirectory(path string, mode os.FileMode) error

CreateDirectory simply checks if the directory path already exists before attempting to create the directory

func CreateFile

func CreateFile(path string, mode os.FileMode) error

CreateFile simply checks if the file path already exists before attempting to create the file

func CreateSymlink(source string, target string) error

CreateSymlink simply creates a symbolic link after verifing the source exists

func DeleteDirectory

func DeleteDirectory(path string) error

DeleteDirectory simply checks if the directory path already exists before attempting to delete the directory

func DeleteDirectoryAll

func DeleteDirectoryAll(path string) error

DeleteDirectoryAll simply checks if the directory path already exists before attempting to delete the directory and any child paths

func DeleteFile

func DeleteFile(path string) error

DeleteFile simply deletes a file if it exists

func FileExtension

func FileExtension(filepath string) (string, error)

FileExtension simply returns the Extension from a File Path in format of <filename>.<extension> (e.g. .json|.yaml|.txt etc)

func HomeDirectory

func HomeDirectory() (string, error)

HomeDirectory returns the home directory for the executing user. This uses an OS-specific method for discovering the home directory. An error is returned if a home directory cannot be detected. SEE: https://github.com/mitchellh/go-homedir/blob/master/homedir.go

func PathExists

func PathExists(path string) (bool, error)

PathExists simply checks if a path exists on the filesystem Returns TRUE if the path does exist Returns FALSE if the path does *not* exist

func PathNotExists

func PathNotExists(path string) (bool, error)

PathNotExists simply checks if a path does *not* exist on the filesystem Returns TRUE if the path does *not* exist Returns FALSE if the path does exist

func ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile simply checks if the file path already exists before attempting to read the file if successful, returns a []byte array of data

func WriteFile

func WriteFile(path string, mode os.FileMode, data []byte) error

WriteFile simply checks if the file path already exists before attempting to create and write the file

Types

This section is empty.

Jump to

Keyboard shortcuts

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