ds

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: MIT Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(fileName string, content string)

Append 往文件尾部添加字符串

func AppendHead

func AppendHead(fileName string, content string)

Append 往文件尾部添加字符串

func Clear

func Clear(dst string) error

Clear 清空目录,包括目录本身

func ClearDir

func ClearDir(dst string) error

ClearDir 清空目录,不包括目录本身

func Copy

func Copy(src, dst string) error

Copy 拷贝文件或目录

func CopyDir

func CopyDir(source string, dst string) error

CopyDir 拷贝文件夹和所有子文件夹

func CopyFile

func CopyFile(src, dst string) (err error)

CopyFile 拷贝文件

func Create

func Create(fileName string) (*os.File, error)

Create 创建一个不存在的文件(已存在则忽略)

func CreateDir

func CreateDir(dirName string) error

CreateDir 创建不存在的文件夹

func Each

func Each(dir string, fn func(fileName string, fi os.FileInfo)) error

Each 遍历指定目录及所有子目录下的所有文件(包括目录本身)

func EachFiles

func EachFiles(dir string, fn func(fileName string, fi os.FileInfo)) error

EachFiles 遍历指定目录及所有子目录下的所有文件

func EachFilesToAppendHead

func EachFilesToAppendHead(dir string, content string, options map[string]any) error

EachFilesToAppendHead 遍历目录下的所有文件,添加文件头

func EachFilesToRemove

func EachFilesToRemove(dir string, fn func(fileName string, fi os.FileInfo) bool) error

EachFilesToRemove 遍历文件夹,当回调函数返回true的时候删除文件 注意,当一个目录下所有文件都被删除,这个目录本身也不会被删除

func EachFilesToRename

func EachFilesToRename(dir string, fn func(oldName string) string) (err error)

批量重命名指定目录及所有子目录下的所有文件。(不包含目录)

func GetFiles

func GetFiles(dir, suffix string) (files []string, err error)

GetFiles 获取指定目录及所有子目录下的所有文件,可以匹配后缀过滤。(不包含目录本身)

func GetFirstFiles

func GetFirstFiles(dir string) ([]fs.DirEntry, error)

GetFirstFiles

func IsExist

func IsExist(path string) bool

IsExist 检查文件或目录是否存在

func Load

func Load(url string, fileName string) error

Load 下载保存

func MustCreate

func MustCreate(fileName string) *os.File

MustCreate 创建文件

func MustRead

func MustRead(fileName string) []byte

func OpenOrCreate

func OpenOrCreate(fileName string, flag int, perm os.FileMode) (*os.File, error)

OpenOrCreate 创建不存在的文件

func ReadFile

func ReadFile(fileName string) ([]byte, error)

func Remove added in v1.1.2

func Remove(fileName string) error

func Save

func Save(fileName string, data []byte) error

Save 保存图片

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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