Update dependencies

Among others, this updates minio-go, so that the new "eu-west-3" zone
for AWS is supported.
This commit is contained in:
Alexander Neumann
2018-01-23 19:40:42 +01:00
parent b63de7c798
commit 2b39f9f4b2
3435 changed files with 1317989 additions and 315639 deletions
+24
View File
@@ -65,8 +65,10 @@ package fields
import (
"bytes"
"errors"
"reflect"
"sort"
"strings"
"cloud.google.com/go/internal/atomiccache"
)
@@ -442,3 +444,25 @@ func dominantField(fs []Field) (Field, bool) {
}
return fs[0], true
}
// ParseStandardTag extracts the sub-tag named by key, then parses it using the
// de facto standard format introduced in encoding/json:
// "-" means "ignore this tag". It must occur by itself. (parseStandardTag returns an error
// in this case, whereas encoding/json accepts the "-" even if it is not alone.)
// "<name>" provides an alternative name for the field
// "<name>,opt1,opt2,..." specifies options after the name.
// The options are returned as a []string.
func ParseStandardTag(key string, t reflect.StructTag) (name string, keep bool, options []string, err error) {
s := t.Get(key)
parts := strings.Split(s, ",")
if parts[0] == "-" {
if len(parts) > 1 {
return "", false, nil, errors.New(`"-" field tag with options`)
}
return "", false, nil, nil
}
if len(parts) > 1 {
options = parts[1:]
}
return parts[0], true, options, nil
}
+12 -15
View File
@@ -19,7 +19,6 @@ import (
"errors"
"fmt"
"reflect"
"strings"
"testing"
"time"
@@ -75,9 +74,10 @@ var intType = reflect.TypeOf(int(0))
func field(name string, tval interface{}, index ...int) *Field {
return &Field{
Name: name,
Type: reflect.TypeOf(tval),
Index: index,
Name: name,
Type: reflect.TypeOf(tval),
Index: index,
ParsedTag: []string(nil),
}
}
@@ -87,6 +87,7 @@ func tfield(name string, tval interface{}, index ...int) *Field {
Type: reflect.TypeOf(tval),
Index: index,
NameFromTag: true,
ParsedTag: []string(nil),
}
}
@@ -103,6 +104,9 @@ func TestFieldsNoTags(t *testing.T) {
field("Em4", int(0), 4, 2, 0),
field("Anonymous", Anonymous(0), 5),
}
for _, f := range want {
f.ParsedTag = nil
}
if msg, ok := compareFields(got, want); !ok {
t.Error(msg)
}
@@ -138,9 +142,10 @@ func TestAgainstJSONEncodingNoTags(t *testing.T) {
Anonymous: Anonymous(15),
}
var want S1
want.embed2 = &embed2{} // need this because reflection won't create it
jsonRoundTrip(t, s1, &want)
var got S1
got.embed2 = &embed2{} // need this because reflection won't create it
got.embed2 = &embed2{}
fields, err := NewCache(nil, nil, nil).Fields(reflect.TypeOf(got))
if err != nil {
t.Fatal(err)
@@ -204,15 +209,7 @@ type tEmbed2 struct {
}
func jsonTagParser(t reflect.StructTag) (name string, keep bool, other interface{}, err error) {
s := t.Get("json")
parts := strings.Split(s, ",")
if parts[0] == "-" {
return "", false, nil, nil
}
if len(parts) > 1 {
other = parts[1:]
}
return parts[0], true, other, nil
return ParseStandardTag("json", t)
}
func validateFunc(t reflect.Type) (err error) {
@@ -408,7 +405,7 @@ func compareFields(got []Field, want []*Field) (msg string, ok bool) {
for i, g := range got {
w := *want[i]
if !fieldsEqual(&g, &w) {
return fmt.Sprintf("got %+v, want %+v", g, w), false
return fmt.Sprintf("got\n%+v\nwant\n%+v", g, w), false
}
}
return "", true