Documentation
¶
Index ¶
- Variables
- func AppendToFile(filepath string, content []byte) error
- func AppendToFileString(filepath, content string) (err error)
- func DirExists(path string) (exist bool, err error)
- func FileExists(path string) (exist bool, err error)
- func IsDirEmpty(dir string) (empty bool, err error)
- func MkdirAll(dir string) (err error)
- func ReadFile(filepath string) (content string, err error)
- func RemoveDir(dirPath string) (err error)
- func RemoveFile(filePath string) (err error)
- func WriteFile(filepath string, content []byte) (err error)
- func WriteFileString(filepath, content string) (err error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrWantDirGotFile = errors.New("expected directory, but found file") ErrWantFileGotDir = errors.New("expected file, but found directory") )
Functions ¶
func AppendToFile ¶
AppendToFile 追加内容到指定文件。
如果文件存在,则追加内容;如果文件不存在,则创建新文件并写入内容。
参数:
- filepath: 文件的路径
- content: 需要追加的字节内容
返回值:
- err: 如果写入失败,返回错误信息;否则返回 nil。
func FileExists ¶
func RemoveFile ¶
func WriteFile ¶
WriteFile 写入内容到指定文件。
如果文件已存在,则覆盖原文件内容。
如果文件不存在,则创建新文件并写入内容。
参数:
- filepath: 文件的路径
- content: 需要写入的字节内容
返回值:
- err: 如果写入失败,返回错误信息;否则返回 nil。
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.