fs

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(path string, content string)

Append 往文件尾部添加字符串

func AppendHead

func AppendHead(path string, content string)

Append 往文件尾部添加字符串

func Create

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

Create

func EachFiles

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

EachFiles 获取指定目录及所有子目录下的所有文件

func EachFilesAppendHead

func EachFilesAppendHead(dir string, content string, options map[string]interface{}) error

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

func EachFilesRemove

func EachFilesRemove(dir string, fn func(filename string, fi os.FileInfo) bool) error

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

func EachFilesRename

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

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

func GetFiles

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

GetFiles 获取指定目录及所有子目录下的所有文件,可以匹配后缀过滤。

func IsExist

func IsExist(fileName string) bool

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

func MkdirNotExist

func MkdirNotExist(path string) error

MkdirNotExist 创建不存在的文件夹

func MustCreate

func MustCreate(name string) *os.File

MustCreate

func MustReadFile

func MustReadFile(path string) []byte

func MustReadText

func MustReadText(path string) string

MustReadText 读取文本文件,当发生错误的时候直接panic

func OpenOrCreate

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

OpenOrCreate 创建不存在的文件

func ReadJSON

func ReadJSON(path string, e interface{}) error

ReadJSON

func ReadJSONToMap

func ReadJSONToMap(path string) (data map[string]interface{}, err error)

ReadJSONToMap

func SaveFile

func SaveFile(path string, data []byte) error

SaveFile 保存图片

func SaveJSON

func SaveJSON(path string, e interface{}) error

SaveJSON 保存为json文件

Types

This section is empty.

Jump to

Keyboard shortcuts

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