filebatch

package
v0.17.1-0...-36a5d2c Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLineRange = errors.New("naza.filebatch: line range error")

Functions

func AddHeadContent

func AddHeadContent(content []byte, head []byte) []byte

文件头部添加内容

func AddTailContent

func AddTailContent(content []byte, tail []byte) []byte

文件尾部添加内容

func DeleteLines

func DeleteLines(content []byte, lr LineRange) ([]byte, error)

func Walk

func Walk(root string, recursive bool, suffix string, walkFn WalkFunc) error

遍历访问指定文件夹下的文件 @param root 需要遍历访问的文件夹 @param recursive 是否递归访问子文件夹 @param suffix 指定文件名后缀进行过滤,如果为"",则不过滤

Types

type LineRange

type LineRange struct {
	From int
	To   int
}

行号范围 1表示首行,-1表示最后一行

type WalkFunc

type WalkFunc func(path string, info os.FileInfo, content []byte, err error) []byte

@param path 带路径的文件名 @param info 文件的 os.FileInfo 信息 @param content 文件内容 @return 返回nil或者content原始内容,则不修改文件内容,返回其他内容,则会覆盖重写文件

Jump to

Keyboard shortcuts

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