file

package module
v0.0.0-...-828dbfb Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

gofile

A set of helper functions for file operations

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendString

func AppendString(filePath string, data string) (err error)

AppendString appends string data to a file. It creates distFile in case not exists, and truncates distFile in case already exists.

func ClearDir

func ClearDir(dirPath string) (err error)

ClearDir removes all files in a directory.

func Copy

func Copy(srcFilePath string, dstFilePath string) (err error)

Copy file from srcFilePath to dstFilePath.

func CountLine

func CountLine(filePath string) (count int, err error)

CountLine returns line count of given file.

func Exists

func Exists(filePath string) bool

Exists checks if a file or directory exists.

func GetAllFiles

func GetAllFiles(dirPath string, suffix string) (filePaths []string, err error)

GetAllFiles returns all files in a directory. If suffix is not empty, it returns only files of specified suffix.

func IsReadable

func IsReadable(filePath string) bool

IsReadable checks if a file or directory can be read.

func MakeDir

func MakeDir(dirPath string) error

MakeDir creates a directory recursively.

func Read

func Read(filePath string) (string, error)

Read whole content string of a file.

func Remove

func Remove(filePath string) error

Remove removes given filePath and any children it contains.

func Rename

func Rename(oldFilePath string, newFilePath string) error

Rename a file or directory.

func Write

func Write(filePath string, data string) error

Write string data into file. It creates file if not exists, and overwrite whole content in case file already exists.

Types

This section is empty.

Jump to

Keyboard shortcuts

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