From 0d5e85c10ce369e63eee41f68383f004a8dee380 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 8 Jul 2019 09:22:59 +0800 Subject: [PATCH] fix vendor --- go.mod | 1 + go.sum | 2 ++ vendor/gopkg.in/yaml.v2/encode.go | 28 ++++++++++++++++++++++++++++ vendor/modules.txt | 2 +- 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 617e814c79011..1ab12a3bc7ad4 100644 --- a/go.mod +++ b/go.mod @@ -128,6 +128,7 @@ require ( gopkg.in/src-d/go-git.v4 v4.12.0 gopkg.in/stretchr/testify.v1 v1.2.2 // indirect gopkg.in/testfixtures.v2 v2.5.0 + gopkg.in/yaml.v2 v2.2.2 // indirect mvdan.cc/xurls/v2 v2.0.0 strk.kbt.io/projects/go/libravatar v0.0.0-20160628055650-5eed7bff870a xorm.io/builder v0.3.5 diff --git a/go.sum b/go.sum index a59a127980814..019ce35e145a9 100644 --- a/go.sum +++ b/go.sum @@ -448,6 +448,8 @@ gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= mvdan.cc/xurls/v2 v2.0.0 h1:r1zSOSNS/kqtpmATyMMMvaZ4/djsesbYz5kr0+qMRWc= mvdan.cc/xurls/v2 v2.0.0/go.mod h1:2/webFPYOXN9jp/lzuj0zuAVlF+9g4KPFJANH1oJhRU= strk.kbt.io/projects/go/libravatar v0.0.0-20160628055650-5eed7bff870a h1:8q33ShxKXRwQ7JVd1ZnhIU3hZhwwn0Le+4fTeAackuM= diff --git a/vendor/gopkg.in/yaml.v2/encode.go b/vendor/gopkg.in/yaml.v2/encode.go index a14435e82f84f..0ee738e11b673 100644 --- a/vendor/gopkg.in/yaml.v2/encode.go +++ b/vendor/gopkg.in/yaml.v2/encode.go @@ -13,6 +13,19 @@ import ( "unicode/utf8" ) +// jsonNumber is the interface of the encoding/json.Number datatype. +// Repeating the interface here avoids a dependency on encoding/json, and also +// supports other libraries like jsoniter, which use a similar datatype with +// the same interface. Detecting this interface is useful when dealing with +// structures containing json.Number, which is a string under the hood. The +// encoder should prefer the use of Int64(), Float64() and string(), in that +// order, when encoding this type. +type jsonNumber interface { + Float64() (float64, error) + Int64() (int64, error) + String() string +} + type encoder struct { emitter yaml_emitter_t event yaml_event_t @@ -89,6 +102,21 @@ func (e *encoder) marshal(tag string, in reflect.Value) { } iface := in.Interface() switch m := iface.(type) { + case jsonNumber: + integer, err := m.Int64() + if err == nil { + // In this case the json.Number is a valid int64 + in = reflect.ValueOf(integer) + break + } + float, err := m.Float64() + if err == nil { + // In this case the json.Number is a valid float64 + in = reflect.ValueOf(float) + break + } + // fallback case - no number could be obtained + in = reflect.ValueOf(m.String()) case time.Time, *time.Time: // Although time.Time implements TextMarshaler, // we don't want to treat it as a string for YAML diff --git a/vendor/modules.txt b/vendor/modules.txt index b68a8d5dbc474..9dc52c541183a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -478,7 +478,7 @@ gopkg.in/src-d/go-git.v4/plumbing/transport/server gopkg.in/testfixtures.v2 # gopkg.in/warnings.v0 v0.1.2 gopkg.in/warnings.v0 -# gopkg.in/yaml.v2 v2.2.1 +# gopkg.in/yaml.v2 v2.2.2 gopkg.in/yaml.v2 # mvdan.cc/xurls/v2 v2.0.0 mvdan.cc/xurls/v2