Fix a bug : trim spaces of the data

This commit is contained in:
weizili.build9 2017-03-10 19:27:36 +08:00
parent 35014aec6e
commit 7ac81fe784
3 changed files with 8 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import (
"github.com/zieckey/goini" "github.com/zieckey/goini"
"os" "os"
"path/filepath" "path/filepath"
"log"
) )
const DataPrefix = "Data|" const DataPrefix = "Data|"
@ -50,6 +51,7 @@ func LookupChartFiles(dir string) ([]string, error) {
if ok, err := filepath.Match("*.chart", f.Name()); err != nil { if ok, err := filepath.Match("*.chart", f.Name()); err != nil {
return err return err
} else if ok { } else if ok {
log.Printf("Add chart file %v", path)
files = append(files, path) files = append(files, path)
} }
return nil return nil

View File

@ -26,9 +26,10 @@ func (c *SplineChart) Parse(ini *goini.INI) (map[string]string, error) {
continue continue
} }
dd := strings.Split(v, ", ") dd := strings.Split(v, ",")
jd := make([]interface{}, 0) jd := make([]interface{}, 0)
for _, d := range dd { for _, d := range dd {
d = strings.TrimSpace(d)
val, err := strconv.ParseFloat(d, 64) val, err := strconv.ParseFloat(d, 64)
if err == nil { if err == nil {
jd = append(jd, val) jd = append(jd, val)

4
glide.yaml Normal file
View File

@ -0,0 +1,4 @@
package: github.com/zieckey/gochart
import:
- package: github.com/bitly/go-simplejson
- package: github.com/zieckey/goini