Documentation
¶
Index ¶
- Variables
- func AlterFile(path string, data []byte) error
- func AlterFileWithString(path string, content string, fileMod fs.FileMode) error
- func AlterFileWithStringFast(path string, content string) error
- func AppendFileHead(path string, content []byte) error
- func AppendFileTail(path string, content []byte) error
- func CheckOrCreateFileWithString(path string, content string, fileMod fs.FileMode) error
- func CheckOrCreateFileWithStringFast(path string, context string) error
- func CopyFile(sourcePath string, target string, perm os.FileMode, coverage bool) error
- func CreateEmptyFile(path string, perm os.FileMode) error
- func FetchDefaultFolderFileMode() fs.FileMode
- func Mkdir(path string) error
- func PathExists(path string) (bool, error)
- func PathExistsFast(path string) bool
- func PathIsDir(path string) bool
- func ReadFileAsByte(path string) ([]byte, error)
- func ReadFileAsJson(path string, v interface{}) error
- func ReadFileAsLines(path string) ([]string, error)
- func ReplaceFileLineByLine(path string, reg string, index int, replace string) error
- func RmDir(path string, force bool) error
- func WriteFileAsJson(path string, v interface{}, fileMod fs.FileMode, coverage, beauty bool) error
- func WriteFileAsJsonBeauty(path string, v interface{}, coverage bool) error
- func WriteFileByByte(path string, data []byte, fileMod fs.FileMode, coverage bool) error
Constants ¶
This section is empty.
Variables ¶
var CreateEmptyFilePathExisted = errors.New("create empty file path is existed")
Functions ¶
func AlterFile ¶
AlterFile
alter file @param path string @param data []byte
this method will keep file mode if file not exist, will not create file and return error
func AlterFileWithString ¶
AlterFileWithString
check or file with content, if file exist, will coverage @param path string @param content string @param fileMod os.FileMode(0o666) os.FileMode(0o644)
func AlterFileWithStringFast ¶
AlterFileWithStringFast
check or file with content, if file exist, will coverage crate folder of file with os.FileMode(0o666) @param path string @param content string
func AppendFileHead ¶
AppendFileHead
append file head @param path string @param content []byte
this method will keep file mode if file not exist, will not create file and return error
func AppendFileTail ¶
AppendFileTail
append file tail @param path string @param content []byte
this method will keep file mode if file not exist, will not create file and return error
func CheckOrCreateFileWithString ¶
CheckOrCreateFileWithString
check or create file with content, if file exist, will not coverage @param path string @param content string @param fileMod os.FileMode(0o666) os.FileMode(0o644)
func CheckOrCreateFileWithStringFast ¶
CheckOrCreateFileWithStringFast
check or create file with content, if file exist, will not coverage crate folder of file with os.FileMode(0o666) @param path string @param content string
func CopyFile ¶ added in v1.8.0
CopyFile
sourcePath is the path to the file in the embedded filesystem. target is the target path where the file will be copied. perm is the permission mode of the target file. os.FileMode(0o644) or os.FileMode(0o666) coverage true will coverage old
func CreateEmptyFile ¶ added in v1.9.0
CreateEmptyFile
path is the target path where the file crate. perm is the permission mode of the target file. os.FileMode(0o644) or os.FileMode(0o666)
if path is exist, will return CreateEmptyFilePathExisted.
func FetchDefaultFolderFileMode ¶ added in v1.7.1
FetchDefaultFolderFileMode if in windows, will return os.FileMode(0o766), windows not support umask
use umask to get folder file mode
if not windows, will use umask, will return os.FileMode(0o777) - umask not support umask will use os.FileMode(0o777).
func ReadFileAsLines ¶ added in v1.3.0
ReadFileAsLines
read file as lines, this method will read all line, so if file is too big, will be slow.
func ReplaceFileLineByLine ¶ added in v1.4.0
ReplaceFileLineByLine
read file as lines, this method will read all line, so if file is too big, will be slow
func WriteFileAsJson ¶ added in v1.1.1
WriteFileAsJson write json file
path most use Abs Path v data fileMod os.FileMode(0o666) or os.FileMode(0o644) coverage true will coverage old beauty will format json when write
func WriteFileAsJsonBeauty ¶ added in v1.1.1
WriteFileAsJsonBeauty
write json file as 0666 and beauty
Types ¶
This section is empty.