From 7ac81fe784b0a6c7e66bdcd543aa1f71d8500c78 Mon Sep 17 00:00:00 2001 From: "weizili.build9" Date: Fri, 10 Mar 2017 19:27:36 +0800 Subject: [PATCH] Fix a bug : trim spaces of the data --- chart_parser.go | 2 ++ chart_parser_spline.go | 3 ++- glide.yaml | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 glide.yaml diff --git a/chart_parser.go b/chart_parser.go index 92fe515..06b7d0f 100644 --- a/chart_parser.go +++ b/chart_parser.go @@ -5,6 +5,7 @@ import ( "github.com/zieckey/goini" "os" "path/filepath" + "log" ) const DataPrefix = "Data|" @@ -50,6 +51,7 @@ func LookupChartFiles(dir string) ([]string, error) { if ok, err := filepath.Match("*.chart", f.Name()); err != nil { return err } else if ok { + log.Printf("Add chart file %v", path) files = append(files, path) } return nil diff --git a/chart_parser_spline.go b/chart_parser_spline.go index 9b2ecb4..d80eff6 100644 --- a/chart_parser_spline.go +++ b/chart_parser_spline.go @@ -26,9 +26,10 @@ func (c *SplineChart) Parse(ini *goini.INI) (map[string]string, error) { continue } - dd := strings.Split(v, ", ") + dd := strings.Split(v, ",") jd := make([]interface{}, 0) for _, d := range dd { + d = strings.TrimSpace(d) val, err := strconv.ParseFloat(d, 64) if err == nil { jd = append(jd, val) diff --git a/glide.yaml b/glide.yaml new file mode 100644 index 0000000..4bf2404 --- /dev/null +++ b/glide.yaml @@ -0,0 +1,4 @@ +package: github.com/zieckey/gochart +import: +- package: github.com/bitly/go-simplejson +- package: github.com/zieckey/goini