|
|
@ -23,12 +23,8 @@ type PrintTask struct { |
|
|
|
PrintDetailList []PrintDetail |
|
|
|
} |
|
|
|
|
|
|
|
type ByteFile struct { |
|
|
|
ByteLine []byte |
|
|
|
} |
|
|
|
|
|
|
|
// 基于模板将打印任务转换成字节码输出
|
|
|
|
func (t *PrintTask) GenBytesFile(conf *conf.EnvConfig) ([]ByteFile, error) { |
|
|
|
func (t *PrintTask) GenBytesFile(conf *conf.EnvConfig) ([]common.ByteFile, error) { |
|
|
|
TemplatePath := common.EnsureDir(conf.TemplatePath) |
|
|
|
templatefile := filepath.Join(TemplatePath, t.PrintHead.TemplateFile) |
|
|
|
f, err := os.Open(templatefile) |
|
|
@ -39,7 +35,7 @@ func (t *PrintTask) GenBytesFile(conf *conf.EnvConfig) ([]ByteFile, error) { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
var results []ByteFile |
|
|
|
var results []common.ByteFile |
|
|
|
scanner := bufio.NewScanner(f) |
|
|
|
for scanner.Scan() { |
|
|
|
linetext := scanner.Text() |
|
|
@ -47,7 +43,7 @@ func (t *PrintTask) GenBytesFile(conf *conf.EnvConfig) ([]ByteFile, error) { |
|
|
|
// -1 替换所有; 1 替换第一个; 5 替换前5个
|
|
|
|
linetext = strings.Replace(linetext, pd.VarName, pd.VarValue, -1) |
|
|
|
} |
|
|
|
var r ByteFile |
|
|
|
var r common.ByteFile |
|
|
|
r.ByteLine = []byte(linetext) |
|
|
|
results = append(results, r) |
|
|
|
} |
|
|
|