Documentation
¶
Overview ¶
Package fileutil implements some basic functions for file operations
Index ¶
- func ClearFile(path string) error
- func CopyFile(srcFilePath string, dstFilePath string) error
- func CreateDir(absPath string) error
- func CreateFile(path string) bool
- func CurrentPath() string
- func FileMode(path string) (fs.FileMode, error)
- func FileSize(path string) (int64, error)
- func IsDir(path string) bool
- func IsExist(path string) bool
- func IsLink(path string) bool
- func IsZipFile(filepath string) bool
- func ListFileNames(path string) ([]string, error)
- func MTime(filepath string) (int64, error)
- func MiMeType(file interface{}) string
- func ReadCsvFile(filepath string) ([][]string, error)
- func ReadFile(path string) (reader io.ReadCloser, closeFn func(), err error)
- func ReadFileByLine(path string) ([]string, error)
- func ReadFileToString(path string) (string, error)
- func RemoveFile(path string) error
- func Sha(filepath string, shaType ...int) (string, error)
- func UnZip(zipFile string, destPath string) error
- func WriteBytesToFile(filepath string, content []byte) error
- func WriteCsvFile(filepath string, records [][]string, append bool) error
- func WriteStringToFile(filepath string, content string, append bool) error
- func Zip(path string, destPath string) error
- func ZipAppendEntry(fpath string, destPath string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateDir ¶ added in v1.3.0
CreateDir create directory in absolute path. param `absPath` like /a/, /a/b/
func CurrentPath ¶ added in v1.3.8
func CurrentPath() string
CurrentPath return current absolute path.
func ListFileNames ¶
ListFileNames return all file names in the path
func MiMeType ¶ added in v1.1.8
func MiMeType(file interface{}) string
MiMeType return file mime type param `file` should be string(file path) or *os.File
func ReadCsvFile ¶ added in v1.3.8
ReadCsvFile read file content into slice.
func ReadFile ¶ added in v1.4.2
func ReadFile(path string) (reader io.ReadCloser, closeFn func(), err error)
ReadFile get file reader by a url or a local file.
func ReadFileByLine ¶ added in v1.0.6
ReadFileByLine read file line by line
func ReadFileToString ¶ added in v1.0.6
ReadFileToString return string of file content
func WriteBytesToFile ¶ added in v1.3.9
WriteBytesToFile write bytes to target file.
func WriteCsvFile ¶ added in v1.4.0
WriteCsvFile write content to target csv file.
func WriteStringToFile ¶ added in v1.3.9
WriteStringToFile write string to target file.
func ZipAppendEntry ¶ added in v1.4.0
ZipAppendEntry append a single file or directory by fpath to an existing zip file. Play: https://go.dev/play/p/cxvaT8TRNQp
Types ¶
This section is empty.