调整结构

This commit is contained in:
2025-09-25 13:48:00 +08:00
parent 7cbb4b2cf9
commit 1cec74cec7
3 changed files with 13 additions and 0 deletions
+9
View File
@@ -23,11 +23,13 @@ func NewSingleFile(templater *template.Template) *SingleFile {
func (s *SingleFile) ParseTemKey(filename string, Keyword config.ErlangTemKey) ([]string, error) {
// 解析整个文件
erlangFile, err := parser.ParseErlangFile(filename)
if err != nil {
return nil, err
}
// 格式化 模板参数
var result []string
for _, function := range erlangFile.Functions {
if len(function.KeyMap[Keyword.Name]) == 0 {
@@ -64,6 +66,8 @@ func (s *SingleFile) ParseTemKey(filename string, Keyword config.ErlangTemKey) (
}
return result, nil
}
// 去除空行
func removeEmptyLinesUniversal(text string) string {
var result strings.Builder
scanner := bufio.NewScanner(strings.NewReader(text))
@@ -81,6 +85,11 @@ func removeEmptyLinesUniversal(text string) string {
// FindConfigXMLPath 1. 打印当前 exe 文件夹内的 config.xml 文件的绝对路径
func (s *SingleFile) FindConfigXMLPath(cfgFile string) (string, error) {
// 判断是否是绝对路径若是则直接返回
if filepath.IsAbs(cfgFile) {
return cfgFile, nil
}
// 获取可执行文件所在目录
exePath, err := os.Executable()
if err != nil {