dirfile

package module
v0.0.0-...-59f6936 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

README

dirfile

介绍

文件目录的常见操作

目前包含

文件/目录存在判断

目录下所有文件后缀

文件是否包含某字符串

更新
v1.0.1 版本

更新内容

添加 dirfile.FileContainsStr,用于判断文件是否包含某字符串,可以配合dirfile.FileDirExist进行目录扫描

// 白名单 黑明单 形式, 黑名单优先。含黑名单任意一个的即排除 含白名单任意一个的即保留
//path:文件路径
//targets:白名单
//except:黑名单
//返回结果,字符串切片及错误,切片格式:行数 内容
func FileContainsStr(path string,targets ,except *[]string) ([]string,error) 
安装教程
  1. go get -u -v gitee.com/frankyu365/dirfile
  2. 或者直接 import "gitee.com/frankyu365/dirfile",鼠标移动过去,GoLand会显示Sync packages of xxx
使用说明
  1. import "gitee.com/frankyu365/dirfile"

  2. dirfile.FileDirExist

    //判断文件或目录是否存在
    //参数:path文件或目录路径
    //返回
    //第一个 true:存在 false:不存在
    //第二个 err 错误(非不存在错误)
    func FileDirExist(path string) (bool, error)
    
  3. dirfile.GetAllFiles

    //从指定目录,递归查找某些后缀文件,白名单和黑名单,若白名单、黑名单重复,黑名单优先
    //参数
    //dirPath:指定目录
    //files:文件列表
    //targets:后缀白名单
    //except:后缀黑名单
    //返回错误
    func GetAllFiles(dirPath string,files *[]string,targets *[]string,except *[]string) error
    
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileContainsStr

func FileContainsStr(path string, targets, except *[]string) ([]string, error)

白名单 黑明单 形式, 黑名单优先。含黑名单任意一个的即排除 含白名单任意一个的即保留 path:文件路径 targets:白名单 except:黑名单 返回结果,字符串切片及错误,切片格式:行数 内容

func FileDirExist

func FileDirExist(path string) (bool, error)

判断文件或目录是否存在 参数:path文件或目录路径 返回 第一个 true:存在 false:不存在 第二个 err 错误(非不存在错误)

func GetAllFiles

func GetAllFiles(dirPath string, files *[]string, targets *[]string, except *[]string) error

从指定目录,递归查找某些后缀文件,白名单和黑名单,若白名单、黑名单重复,黑名单优先 参数 dirPath:指定目录 files:文件列表 targets:后缀白名单 except:后缀黑名单 返回错误

Types

This section is empty.

Jump to

Keyboard shortcuts

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