From 3db2aa308d5102b736a29647d4058d07e5e58158 Mon Sep 17 00:00:00 2001 From: aaron <462826@qq.com> Date: Tue, 11 Aug 2020 15:12:18 +0800 Subject: [PATCH] fix issue#3353 --- src/gen/decode.go | 14 ++++++++++---- src/utils/file/file.go | 3 +-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gen/decode.go b/src/gen/decode.go index 70236e0c..1a9f72b6 100644 --- a/src/gen/decode.go +++ b/src/gen/decode.go @@ -8,7 +8,7 @@ import ( i118Utils "github.com/easysoft/zendata/src/utils/i118" logUtils "github.com/easysoft/zendata/src/utils/log" "github.com/easysoft/zendata/src/utils/vari" - "github.com/mattn/go-runewidth" + "log" "strings" ) @@ -17,6 +17,11 @@ const ( ) func Decode(defaultFile, configFile, fieldsToExportStr, input, output string) { + vari.DefaultDir = fileUtils.GetAbsDir(defaultFile) + vari.ConfigDir = fileUtils.GetAbsDir(configFile) + + vari.Total = 10 + fieldsToExport := make([]string, 0) if fieldsToExportStr != "" { fieldsToExport = strings.Split(fieldsToExportStr, ",") @@ -27,7 +32,7 @@ func Decode(defaultFile, configFile, fieldsToExportStr, input, output string) { data := fileUtils.ReadFile(input) - ret := []map[string]interface{}{} + var ret []map[string]interface{} LinesToMap(data, fieldsToExport, &ret) jsonObj, _ := json.Marshal(ret) vari.JsonResp = string(jsonObj) @@ -78,8 +83,9 @@ func decodeOneLevel(line string, fields []model.DefField, rowMap *map[string]int if len(sep) > 0 { index := searchRune(left, sep) if index > -1 { - col = string(left[: index+runewidth.StringWidth(field.Postfix)]) - left = left[index+runewidth.StringWidth(field.Prefix)+1:] + col = string(left[: index + len(field.Postfix)]) + left = left[index + len(field.Postfix):] + log.Println(left) } } else if j == len(fields) - 1 { col = string(left) diff --git a/src/utils/file/file.go b/src/utils/file/file.go index c8686e09..f5d99a50 100644 --- a/src/utils/file/file.go +++ b/src/utils/file/file.go @@ -1,7 +1,6 @@ package fileUtils import ( - "fmt" "github.com/easysoft/zendata/res" commonUtils "github.com/easysoft/zendata/src/utils/common" constant "github.com/easysoft/zendata/src/utils/const" @@ -129,7 +128,7 @@ func GetExeDir() string { // where zd.exe file in dir, _ = filepath.Abs(dir) dir = AddSepIfNeeded(dir) - fmt.Printf("Debug: Launch %s in %s \n", arg1, dir) + //fmt.Printf("Debug: Launch %s in %s \n", arg1, dir) return dir } -- GitLab