fileutil

package
v0.0.0-...-c2da2d2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearFile

func ClearFile(path string) error

ClearFile write empty string to path file. Play: https://go.dev/play/p/NRZ0ZT-G94H

func CopyFile

func CopyFile(srcPath string, dstPath string) error

CopyFile copy src file to dest file. Play: https://go.dev/play/p/Jg9AMJMLrJi

func CreateDir

func CreateDir(absPath string) error

CreateDir create directory in absolute path. param `absPath` like /a/, /a/b/. Play: https://go.dev/play/p/qUuCe1OGQnM

func CreateFile

func CreateFile(path string) bool

CreateFile create a file in path. Play: https://go.dev/play/p/lDt8PEsTNKI

func CurrentPath

func CurrentPath() string

CurrentPath return current absolute path. Play: https://go.dev/play/p/s74a9iBGcSw

func FileMode

func FileMode(path string) (fs.FileMode, error)

FileMode return file's mode and permission. Play: https://go.dev/play/p/2l2hI42fA3p

func FileSize

func FileSize(path string) (int64, error)

FileSize returns file size in bytes. Play: https://go.dev/play/p/H9Z05uD-Jjc

func IsDir

func IsDir(path string) bool

IsDir checks if the path is directory or not. Play: https://go.dev/play/p/WkVwEKqtOWk

func IsExist

func IsExist(path string) bool

IsExist checks if a file or directory exists. Play: https://go.dev/play/p/nKKXt8ZQbmh

func IsLink(path string) bool

IsLink checks if a file is symbol link or not. Play: https://go.dev/play/p/TL-b-Kzvf44

func IsZipFile

func IsZipFile(filepath string) bool

IsZipFile checks if file is zip or not. Play: https://go.dev/play/p/9M0g2j_uF_e

func ListFileNames

func ListFileNames(path string) ([]string, error)

ListFileNames return all file names in the path. Play: https://go.dev/play/p/Tjd7Y07rejl

func MTime

func MTime(filepath string) (int64, error)

MTime returns file modified time. Play: https://go.dev/play/p/s_Tl7lZoAaY

func MiMeType

func MiMeType(file any) string

MiMeType return file mime type param `file` should be string(file path) or *os.File. Play: https://go.dev/play/p/bd5sevSUZNu

func ReadCsvFile

func ReadCsvFile(filepath string) ([][]string, error)

ReadCsvFile read file content into slice. Play: https://go.dev/play/p/OExTkhGEd3_u

func ReadFileByLine

func ReadFileByLine(path string) ([]string, error)

ReadFileByLine read file line by line. Play: https://go.dev/play/p/svJP_7ZrBrD

func ReadFileToString

func ReadFileToString(path string) (string, error)

ReadFileToString return string of file content. Play: https://go.dev/play/p/cmfwp_5SQTp

func RemoveFile

func RemoveFile(path string) error

RemoveFile remove the path file. Play: https://go.dev/play/p/P2y0XW8a1SH

func Sha

func Sha(filepath string, shaType ...int) (string, error)

Sha returns file sha value, param `shaType` should be 1, 256 or 512. Play: https://go.dev/play/p/VfEEcO2MJYf

func UnZip

func UnZip(zipFile string, destPath string) error

UnZip unzip the file and save it to destPath. Play: https://go.dev/play/p/g0w34kS7B8m

func WriteBytesToFile

func WriteBytesToFile(filepath string, content []byte) error

WriteBytesToFile write bytes to target file. Play: https://go.dev/play/p/s7QlDxMj3P8

func WriteStringToFile

func WriteStringToFile(filepath string, content string, append bool) error

WriteStringToFile write string to target file. Play: https://go.dev/play/p/GhLS6d8lH_g

func Zip

func Zip(fpath string, destPath string) error

Zip create zip file, fpath could be a single file or a directory. Play: https://go.dev/play/p/j-3sWBp8ik_P

Types

This section is empty.

Jump to

Keyboard shortcuts

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