From e09b2a6483d4262d3b5cadc8a6f81d539981fc22 Mon Sep 17 00:00:00 2001 From: Joe Tsai Date: Tue, 1 Nov 2016 03:23:35 -0700 Subject: [PATCH 1/2] Fix decode test for Go 1.8 An upstream change (http://golang.org/cl/31144) alters the time package to be more consistent about the representation of UTC location. We adjust the time.Time used in the test to work on both 1.7 and 1.8. --- decode_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decode_test.go b/decode_test.go index 3da6fadf..5c56a00e 100644 --- a/decode_test.go +++ b/decode_test.go @@ -551,7 +551,7 @@ var unmarshalTests = []struct { }, { "a: 2015-02-24T18:19:39Z\n", - map[string]time.Time{"a": time.Unix(1424801979, 0)}, + map[string]time.Time{"a": time.Unix(1424801979, 0).In(time.UTC)}, }, // Encode empty lists as zero-length slices. From 543153189109366780b7e792533a89ca6be180ed Mon Sep 17 00:00:00 2001 From: Vinzenz Feenstra Date: Thu, 3 Nov 2016 10:39:07 +0100 Subject: [PATCH 2/2] Fix for issue go-yaml/yaml#157 --- resolve.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/resolve.go b/resolve.go index 93a86327..0fa116e1 100644 --- a/resolve.go +++ b/resolve.go @@ -135,9 +135,15 @@ func resolve(tag string, in string) (rtag string, out interface{}) { if err == nil { return yaml_INT_TAG, uintv } - floatv, err := strconv.ParseFloat(plain, 64) - if err == nil { - return yaml_FLOAT_TAG, floatv + tryFloat := true + if strings.HasPrefix(plain, "0") { + tryFloat = strings.ContainsRune(plain, '.') + } + if tryFloat { + floatv, err := strconv.ParseFloat(plain, 64) + if err == nil { + return yaml_FLOAT_TAG, floatv + } } if strings.HasPrefix(plain, "0b") { intv, err := strconv.ParseInt(plain[2:], 2, 64)