filesystem

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies a file

func DirectoryExists

func DirectoryExists(dir string) bool

DirectoryExists checks if the dir exists

func ExecutableDir

func ExecutableDir() string

ExecutableDir returns the directory of the current executable

func FileContainsString

func FileContainsString(file string, str string) bool

FileContainsString will check if a file contains the string

func FileExists

func FileExists(filename string) bool

FileExists checks if the file exists

func FindFiles

func FindFiles(rootPath string, ignore IgnoreFunc, filter FilterFunc) ([]string, error)

FindFiles will return all files in a directory ignoreFunc can be used to skip directories or files filterFunc is used to evaluate if a file should be included in the result

func FindFilesByExtension

func FindFilesByExtension(rootPath string, extensions []string) ([]string, error)

FindFilesByExtension will return all files with a specific extension in a directory

func GenerateFileMapByDeepExtension

func GenerateFileMapByDeepExtension(files []string) map[string][]string

GenerateFileMapByDeepExtension will return a map of files by extension Supports multiple dots in the file name, see GenerateFileMapByExtension for one dot Example: {"go": ["file1.go", "file2.go"], "txt": ["file1.txt"], "tar.gz": ["file1.tar.gz"]}

func GenerateFileMapByExtension

func GenerateFileMapByExtension(files []string) map[string][]string

GenerateFileMapByExtension will return a map of files by extension Supports one dot in the file name, see GenerateFileMapByDeepExtension for multiple dots Example: {"go": ["file1.go", "file2.go"], "txt": ["file1.txt"], "gz": ["file1.tar.gz"]}

func GetFileBytes

func GetFileBytes(file string) ([]byte, error)

GetFileBytes will retrieve the content of a file as bytes

func GetFileContent

func GetFileContent(file string) (string, error)

GetFileContent will retrieve the content of a file as text

func GetPathRelativeToDirectory

func GetPathRelativeToDirectory(currentDirectory string, rootDirectory string) string

GetPathRelativeToDirectory returns the relative path in relation to the rootDirectory

func GetProjectDirectory

func GetProjectDirectory() (string, error)

GetProjectDirectory will try to find the project directory based on repository folders (.git)

func MoveFile

func MoveFile(oldLocation string, newLocation string) error

MoveFile will move the file to a new location

func RemoveFile

func RemoveFile(file string) error

RemoveFile will delete a file

func SaveFileText

func SaveFileText(file string, content string) error

SaveFileText will save a file with the provided content

func WorkingDirOrPanic

func WorkingDirOrPanic() string

WorkingDirOrPanic returns the current working directory or panics

Types

type FilterFunc

type FilterFunc func(absPath string, name string) bool

type IgnoreFunc

type IgnoreFunc func(absPath string, name string) bool

Jump to

Keyboard shortcuts

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