Documentation
¶
Overview ¶
Package replacer 是一个用于替换文件内容的库,支持本地目录和嵌入目录文件的替换。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Field ¶
Field 替换字段信息结构体,定义单个字段的替换规则
字段说明:
Old - 要被替换的旧字符串
New - 替换后的新字符串
IsCaseSensitive - 是否区分大小写匹配
当为 true 且首字符为字母时,会自动生成首字母大写和小写两个替换规则
type Replacer ¶
type Replacer interface {
// SetReplacementFields 设置替换字段
SetReplacementFields(fields []Field)
// SetSubDirsAndFiles 设置子目录和文件列表,其他目录中的文件将被忽略
SetSubDirsAndFiles(subDirs []string, subFiles ...string)
// SetIgnoreSubDirs 设置忽略的子目录
SetIgnoreSubDirs(dirs ...string)
// SetIgnoreSubFiles 设置忽略的文件
SetIgnoreSubFiles(filenames ...string)
// SetOutputDir 设置输出目录
SetOutputDir(absDir string, name ...string) error
// GetOutputDir 获取输出目录
GetOutputDir() string
// GetSourcePath 获取源目录
GetSourcePath() string
// SaveFiles 保存文件
SaveFiles() error
// ReadFile 读取文件内容
ReadFile(filename string) ([]byte, error)
// GetFiles 获取文件列表
GetFiles() []string
// SaveTemplateFiles 保存模板文件
SaveTemplateFiles(m map[string]interface{}, parentDir ...string) error
}
Replacer 接口定义了文件替换器的行为
Click to show internal directories.
Click to hide internal directories.