zdpgo_file

package module
v1.1.0 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: 1

README

zdpgo_file

Golang 操作文件或者文件夹的快捷组件

项目地址:https://github.com/zhangdapeng520/zdpgo_file

版本历史

  • v0.1.0 2022/02/07
  • v0.1.1 2022/04/03
  • v0.1.2 2022/04/21
  • v0.1.3 2022/05/02 新增:替换指定目录下的文件名
  • v0.1.4 2022/05/12 新增:指定目录创建和删除文件
  • v1.0.2 2022/05/12 BUG 修复:历史遗留 BUG
  • v1.0.3 2022/05/17 升级:升级日志组件
  • v1.0.4 2022/05/21 升级:整体代码重构
  • v1.0.5 2022/05/21 BUG 修复:解决无法正常移除文件后缀的 BUG
  • v1.0.6 2022/05/28 优化:移除日志
  • v1.0.7 2022/07/13 新增:批量重命名目录
  • v1.0.8 2022/08/02 新增:处理文件夹中每个文件
  • v1.0.9 2022/08/02 新增:处理文件夹文件并支持忽略指定列表文件夹
  • v1.1.0 2022/08/17 优化:所有方法改为可直接调用

使用示例

请查看 examples 目录

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile added in v1.1.0

func CopyFile(src, dest string) bool

CopyFile 复制文件 @param src 源文件地址 @param dest 目标文件地址

func CreateDir added in v1.0.8

func CreateDir(dirtPath string) bool

CreateDir 调用os.MkdirAll递归创建文件夹

func CreateDirFile added in v1.0.8

func CreateDirFile(dirtPath, fileName, content string) bool

CreateDirFile 在指定文件夹中创建文件

func CreateFile added in v1.1.0

func CreateFile(filePath, content string) bool

CreateFile 创建文件

func DeleteDir added in v1.0.8

func DeleteDir(dirPath string) bool

DeleteDir 删除文件夹

func DeleteDirFile added in v1.0.8

func DeleteDirFile(dirPath, fileName string) bool

DeleteDirFile 删除指定目录中的指定文件

func GetDirSize added in v1.1.0

func GetDirSize(path string) (int64, error)

GetDirSize 文件夹占用磁盘大小

func GetFileDir added in v1.1.0

func GetFileDir(absolutePath string) (fileDir string)

GetFileDir 获取文件路径

func GetFileDirAndFileName added in v1.1.0

func GetFileDirAndFileName(absolutePath string) (fileDir string, fileName string)

GetFileDirAndFileName 获取文件路径和文件名

func GetFileName added in v1.1.0

func GetFileName(absolutePath string) (fileName string)

GetFileName 获取文件名称

func GetFileNameNoSuffix added in v1.1.0

func GetFileNameNoSuffix(absolutePath string) (fileName string)

GetFileNameNoSuffix 获取文件名称,不包含后缀

func GetFileSize added in v1.1.0

func GetFileSize(path string) int64

GetFileSize 获取文件大小

func GetFileSuffix added in v1.1.0

func GetFileSuffix(absolutePath string) (suffix string)

GetFileSuffix 获取文件后缀

func HandleDirFile added in v1.0.8

func HandleDirFile(dirPath string, handleFunc func(filePath string)) error

HandleDirFile 使用handleFunc处理文件夹中的每个文件

func HandleDirFileWithIgnoreDirList added in v1.0.9

func HandleDirFileWithIgnoreDirList(dirPath string, handleFunc func(filePath string), ignoreDirList []string) error

HandleDirFileWithIgnoreDirList 处理文件夹中的文件,并支持指定忽略的文件夹

func IsDir added in v1.1.0

func IsDir(dirPath string) bool

IsDir 判断所给路径是否为文件夹

func IsDirContainsFile added in v1.1.0

func IsDirContainsFile(dirPath, fileName string) bool

IsDirContainsFile 判断文件夹中是否包含指定文件

func IsExists added in v1.0.8

func IsExists(path string) bool

IsExists 判断所给路径文件/文件夹是否存在(返回true是存在)

func IsFile added in v1.1.0

func IsFile(path string) bool

IsFile 判断所给路径是否为文件

func ReadCsv added in v1.1.0

func ReadCsv(fileName string) (data [][]string, err error)

ReadCsv 读取csv

func RemoveDirFilesSuffix added in v1.1.0

func RemoveDirFilesSuffix(dirPath string) bool

RemoveDirFilesSuffix 去掉指定目录下所有文件的后缀

func ReplaceDirFilesName added in v1.1.0

func ReplaceDirFilesName(dirPath string, oldStr, newStr string) bool

ReplaceDirFilesName 替换指定目录下的文件名

func ReplaceDirName added in v1.1.0

func ReplaceDirName(dirPath string, oldStr, newStr string) bool

ReplaceDirName 替换文件夹名

func WriteCsv added in v1.1.0

func WriteCsv(filePath string, data [][]string) bool

WriteCsv 将数据保存为csv文件

Types

This section is empty.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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