Documentation
¶
Index ¶
- func Copy(srcFile, dstFile string) (errToReturn error)
- func CopyDirectory(scrDir, dest string) error
- func CopySymLink(source, dest string) error
- func CreateIfNotExists(dir string, perm os.FileMode) error
- func Exists(filePath string) bool
- func FileExists(filename string) bool
- func ReadFile(path string) ([]byte, error)
- func TerminateOnFullDisk(err error) error
- func WriteFile(path string, data []byte) error
- func WriteJSON(path string, data interface{}) error
- func WriteText(path string, data []byte) error
- type FileLock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyDirectory ¶ added in v0.16.1
CopyDirectory recursively copies a directory. From https://stackoverflow.com/questions/51779243/copy-a-folder-in-go
func CopySymLink ¶ added in v0.16.1
func CreateIfNotExists ¶ added in v0.16.1
func FileExists ¶ added in v0.14.0
func ReadFile ¶
ReadFile reads the file from path, if not found, it will print the absolute path, instead of relative path.
func TerminateOnFullDisk ¶ added in v0.28.0
TerminateOnFullDisk panics if the input error is (or wraps) the system "out of disk space" error. It's a no-op for any other error, or nil.
func WriteFile ¶ added in v0.15.0
WriteFile writes a byte array to the file at the given path. This method will also create the directory and file as needed.
Types ¶
type FileLock ¶
type FileLock struct {
// contains filtered or unexported fields
}
FileLock represents an exclusive file lock that prevents multiple processes from accessing the same resource. If another process tries to acquire the lock, it will fail and should crash.
func NewFileLock ¶
NewFileLock creates a new file lock at the specified path. The lock file will be created in the same directory as the path. If path is a directory, the lock file will be created inside it. If the directory doesn't exist yet, it assumes the path is intended to be a directory.
func (*FileLock) IsLocked ¶
IsLocked returns true if this FileLock instance currently holds the lock.