From 69ad6a78226501377e0264cbd4d9e9a26e41fe0d Mon Sep 17 00:00:00 2001 From: WAKAYAMA Shirou Date: Thu, 12 Feb 2015 22:34:00 +0900 Subject: [PATCH] fix new line problem on Windows --- common/common.go | 2 +- common/common_test.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/common/common.go b/common/common.go index fc0c6dd..1b77e36 100644 --- a/common/common.go +++ b/common/common.go @@ -113,7 +113,7 @@ func mustParseFloat64(val string) float64 { // Check the target string slice containes src or not func StringContains(target []string, src string) bool { for _, t := range target { - if t == src { + if strings.TrimSpace(t) == src { return true } } diff --git a/common/common_test.go b/common/common_test.go index e72d8b9..231fb47 100644 --- a/common/common_test.go +++ b/common/common_test.go @@ -2,6 +2,7 @@ package common import ( "fmt" + "strings" "testing" ) @@ -10,7 +11,7 @@ func TestReadlines(t *testing.T) { if err != nil { t.Error(err) } - if ret[0] != "package common" { + if !strings.Contains(ret[0], "package common") { t.Error("could not read correctly") } } @@ -21,7 +22,7 @@ func TestReadLinesOffsetN(t *testing.T) { t.Error(err) } fmt.Println(ret[0]) - if ret[0] != `import (` { + if !strings.Contains(ret[0], `import (`) { t.Error("could not read correctly") } } -- GitLab