aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/stretchr/objx
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-09-15 18:05:35 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-09-15 19:34:30 +0200
commit712de1c63d9db97c81af68cd0dc4372c53d2e57a (patch)
treeae1761fec52c3ae4ddd003a4130ddbda8d0a2d69 /vendor/github.com/stretchr/objx
parent298a69c38dd5c8a9bbd7a022e88f4ddbcf885e16 (diff)
vendor/github.com/golangci/golangci-lint: update to v1.31
Diffstat (limited to 'vendor/github.com/stretchr/objx')
-rw-r--r--vendor/github.com/stretchr/objx/.codeclimate.yml8
-rw-r--r--vendor/github.com/stretchr/objx/.travis.yml19
-rw-r--r--vendor/github.com/stretchr/objx/Gopkg.lock30
-rw-r--r--vendor/github.com/stretchr/objx/Gopkg.toml8
-rw-r--r--vendor/github.com/stretchr/objx/README.md2
-rw-r--r--vendor/github.com/stretchr/objx/Taskfile.yml52
-rw-r--r--vendor/github.com/stretchr/objx/accessors.go211
-rw-r--r--vendor/github.com/stretchr/objx/constants.go13
-rw-r--r--vendor/github.com/stretchr/objx/conversions.go188
-rw-r--r--vendor/github.com/stretchr/objx/go.mod8
-rw-r--r--vendor/github.com/stretchr/objx/go.sum8
-rw-r--r--vendor/github.com/stretchr/objx/map.go44
-rw-r--r--vendor/github.com/stretchr/objx/type_specific.go346
-rw-r--r--vendor/github.com/stretchr/objx/type_specific_codegen.go286
-rw-r--r--vendor/github.com/stretchr/objx/value.go106
15 files changed, 874 insertions, 455 deletions
diff --git a/vendor/github.com/stretchr/objx/.codeclimate.yml b/vendor/github.com/stretchr/objx/.codeclimate.yml
index 010d4ccd5..559fa399c 100644
--- a/vendor/github.com/stretchr/objx/.codeclimate.yml
+++ b/vendor/github.com/stretchr/objx/.codeclimate.yml
@@ -10,4 +10,12 @@ exclude_patterns:
- ".github/"
- "vendor/"
- "codegen/"
+- "*.yml"
+- ".*.yml"
+- "*.md"
+- "Gopkg.*"
- "doc.go"
+- "type_specific_codegen_test.go"
+- "type_specific_codegen.go"
+- ".gitignore"
+- "LICENSE"
diff --git a/vendor/github.com/stretchr/objx/.travis.yml b/vendor/github.com/stretchr/objx/.travis.yml
index a63efa59d..cde6eb2af 100644
--- a/vendor/github.com/stretchr/objx/.travis.yml
+++ b/vendor/github.com/stretchr/objx/.travis.yml
@@ -1,8 +1,14 @@
language: go
go:
- - 1.8
- - 1.9
- - tip
+ - "1.10.x"
+ - "1.11.x"
+ - "1.12.x"
+ - master
+
+matrix:
+ allow_failures:
+ - go: master
+fast_finish: true
env:
global:
@@ -14,12 +20,11 @@ before_script:
- ./cc-test-reporter before-build
install:
-- go get github.com/go-task/task/cmd/task
+ - curl -sL https://taskfile.dev/install.sh | sh
script:
-- task dl-deps
-- task lint
-- task test-coverage
+ - diff -u <(echo -n) <(./bin/task lint)
+ - ./bin/task test-coverage
after_script:
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
diff --git a/vendor/github.com/stretchr/objx/Gopkg.lock b/vendor/github.com/stretchr/objx/Gopkg.lock
deleted file mode 100644
index eebe342a9..000000000
--- a/vendor/github.com/stretchr/objx/Gopkg.lock
+++ /dev/null
@@ -1,30 +0,0 @@
-# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
-
-
-[[projects]]
- name = "github.com/davecgh/go-spew"
- packages = ["spew"]
- revision = "346938d642f2ec3594ed81d874461961cd0faa76"
- version = "v1.1.0"
-
-[[projects]]
- name = "github.com/pmezard/go-difflib"
- packages = ["difflib"]
- revision = "792786c7400a136282c1664665ae0a8db921c6c2"
- version = "v1.0.0"
-
-[[projects]]
- name = "github.com/stretchr/testify"
- packages = [
- "assert",
- "require"
- ]
- revision = "b91bfb9ebec76498946beb6af7c0230c7cc7ba6c"
- version = "v1.2.0"
-
-[solve-meta]
- analyzer-name = "dep"
- analyzer-version = 1
- inputs-digest = "2d160a7dea4ffd13c6c31dab40373822f9d78c73beba016d662bef8f7a998876"
- solver-name = "gps-cdcl"
- solver-version = 1
diff --git a/vendor/github.com/stretchr/objx/Gopkg.toml b/vendor/github.com/stretchr/objx/Gopkg.toml
deleted file mode 100644
index d70f1570b..000000000
--- a/vendor/github.com/stretchr/objx/Gopkg.toml
+++ /dev/null
@@ -1,8 +0,0 @@
-[prune]
- unused-packages = true
- non-go = true
- go-tests = true
-
-[[constraint]]
- name = "github.com/stretchr/testify"
- version = "~1.2.0"
diff --git a/vendor/github.com/stretchr/objx/README.md b/vendor/github.com/stretchr/objx/README.md
index be5750c94..246660b21 100644
--- a/vendor/github.com/stretchr/objx/README.md
+++ b/vendor/github.com/stretchr/objx/README.md
@@ -74,7 +74,7 @@ To update Objx to the latest version, run:
go get -u github.com/stretchr/objx
### Supported go versions
-We support the lastest two major Go versions, which are 1.8 and 1.9 at the moment.
+We support the lastest three major Go versions, which are 1.10, 1.11 and 1.12 at the moment.
## Contributing
Please feel free to submit issues, fork the repository and send pull requests!
diff --git a/vendor/github.com/stretchr/objx/Taskfile.yml b/vendor/github.com/stretchr/objx/Taskfile.yml
index f8035641f..a749ac549 100644
--- a/vendor/github.com/stretchr/objx/Taskfile.yml
+++ b/vendor/github.com/stretchr/objx/Taskfile.yml
@@ -1,32 +1,30 @@
-default:
- deps: [test]
+version: '2'
-dl-deps:
- desc: Downloads cli dependencies
- cmds:
- - go get -u github.com/golang/lint/golint
- - go get -u github.com/golang/dep/cmd/dep
+env:
+ GOFLAGS: -mod=vendor
-update-deps:
- desc: Updates dependencies
- cmds:
- - dep ensure
- - dep ensure -update
+tasks:
+ default:
+ deps: [test]
-lint:
- desc: Runs golint
- cmds:
- - go fmt $(go list ./... | grep -v /vendor/)
- - go vet $(go list ./... | grep -v /vendor/)
- - golint $(ls *.go | grep -v "doc.go")
- silent: true
+ lint:
+ desc: Checks code style
+ cmds:
+ - gofmt -d -s *.go
+ - go vet ./...
+ silent: true
-test:
- desc: Runs go tests
- cmds:
- - go test -race .
+ lint-fix:
+ desc: Fixes code style
+ cmds:
+ - gofmt -w -s *.go
-test-coverage:
- desc: Runs go tests and calucates test coverage
- cmds:
- - go test -coverprofile=c.out .
+ test:
+ desc: Runs go tests
+ cmds:
+ - go test -race ./...
+
+ test-coverage:
+ desc: Runs go tests and calucates test coverage
+ cmds:
+ - go test -race -coverprofile=c.out ./...
diff --git a/vendor/github.com/stretchr/objx/accessors.go b/vendor/github.com/stretchr/objx/accessors.go
index 204356a22..80ad16740 100644
--- a/vendor/github.com/stretchr/objx/accessors.go
+++ b/vendor/github.com/stretchr/objx/accessors.go
@@ -1,18 +1,34 @@
package objx
import (
+ "reflect"
"regexp"
"strconv"
"strings"
)
-// arrayAccesRegexString is the regex used to extract the array number
-// from the access path
-const arrayAccesRegexString = `^(.+)\[([0-9]+)\]$`
+const (
+ // PathSeparator is the character used to separate the elements
+ // of the keypath.
+ //
+ // For example, `location.address.city`
+ PathSeparator string = "."
+
+ // arrayAccesRegexString is the regex used to extract the array number
+ // from the access path
+ arrayAccesRegexString = `^(.+)\[([0-9]+)\]$`
+
+ // mapAccessRegexString is the regex used to extract the map key
+ // from the access path
+ mapAccessRegexString = `^([^\[]*)\[([^\]]+)\](.*)$`
+)
// arrayAccesRegex is the compiled arrayAccesRegexString
var arrayAccesRegex = regexp.MustCompile(arrayAccesRegexString)
+// mapAccessRegex is the compiled mapAccessRegexString
+var mapAccessRegex = regexp.MustCompile(mapAccessRegexString)
+
// Get gets the value using the specified selector and
// returns it inside a new Obj object.
//
@@ -46,103 +62,118 @@ func (m Map) Set(selector string, value interface{}) Map {
return m
}
-// access accesses the object using the selector and performs the
-// appropriate action.
-func access(current, selector, value interface{}, isSet bool) interface{} {
- switch selector.(type) {
- case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64:
- if array, ok := current.([]interface{}); ok {
- index := intFromInterface(selector)
- if index >= len(array) {
- return nil
+// getIndex returns the index, which is hold in s by two braches.
+// It also returns s withour the index part, e.g. name[1] will return (1, name).
+// If no index is found, -1 is returned
+func getIndex(s string) (int, string) {
+ arrayMatches := arrayAccesRegex.FindStringSubmatch(s)
+ if len(arrayMatches) > 0 {
+ // Get the key into the map
+ selector := arrayMatches[1]
+ // Get the index into the array at the key
+ // We know this cannt fail because arrayMatches[2] is an int for sure
+ index, _ := strconv.Atoi(arrayMatches[2])
+ return index, selector
+ }
+ return -1, s
+}
+
+// getKey returns the key which is held in s by two brackets.
+// It also returns the next selector.
+func getKey(s string) (string, string) {
+ selSegs := strings.SplitN(s, PathSeparator, 2)
+ thisSel := selSegs[0]
+ nextSel := ""
+
+ if len(selSegs) > 1 {
+ nextSel = selSegs[1]
+ }
+
+ mapMatches := mapAccessRegex.FindStringSubmatch(s)
+ if len(mapMatches) > 0 {
+ if _, err := strconv.Atoi(mapMatches[2]); err != nil {
+ thisSel = mapMatches[1]
+ nextSel = "[" + mapMatches[2] + "]" + mapMatches[3]
+
+ if thisSel == "" {
+ thisSel = mapMatches[2]
+ nextSel = mapMatches[3]
}
- return array[index]
- }
- return nil
-
- case string:
- selStr := selector.(string)
- selSegs := strings.SplitN(selStr, PathSeparator, 2)
- thisSel := selSegs[0]
- index := -1
- var err error
-
- if strings.Contains(thisSel, "[") {
- arrayMatches := arrayAccesRegex.FindStringSubmatch(thisSel)
- if len(arrayMatches) > 0 {
- // Get the key into the map
- thisSel = arrayMatches[1]
-
- // Get the index into the array at the key
- index, err = strconv.Atoi(arrayMatches[2])
-
- if err != nil {
- // This should never happen. If it does, something has gone
- // seriously wrong. Panic.
- panic("objx: Array index is not an integer. Must use array[int].")
- }
+
+ if nextSel == "" {
+ selSegs = []string{"", ""}
+ } else if nextSel[0] == '.' {
+ nextSel = nextSel[1:]
}
}
- if curMap, ok := current.(Map); ok {
- current = map[string]interface{}(curMap)
+ }
+
+ return thisSel, nextSel
+}
+
+// access accesses the object using the selector and performs the
+// appropriate action.
+func access(current interface{}, selector string, value interface{}, isSet bool) interface{} {
+ thisSel, nextSel := getKey(selector)
+
+ index := -1
+ if strings.Contains(thisSel, "[") {
+ index, thisSel = getIndex(thisSel)
+ }
+
+ if curMap, ok := current.(Map); ok {
+ current = map[string]interface{}(curMap)
+ }
+ // get the object in question
+ switch current.(type) {
+ case map[string]interface{}:
+ curMSI := current.(map[string]interface{})
+ if nextSel == "" && isSet {
+ curMSI[thisSel] = value
+ return nil
}
- // get the object in question
- switch current.(type) {
- case map[string]interface{}:
- curMSI := current.(map[string]interface{})
- if len(selSegs) <= 1 && isSet {
- curMSI[thisSel] = value
- return nil
- }
- current = curMSI[thisSel]
- default:
- current = nil
+
+ _, ok := curMSI[thisSel].(map[string]interface{})
+ if (curMSI[thisSel] == nil || !ok) && index == -1 && isSet {
+ curMSI[thisSel] = map[string]interface{}{}
}
- // do we need to access the item of an array?
- if index > -1 {
- if array, ok := current.([]interface{}); ok {
- if index < len(array) {
- current = array[index]
- } else {
- current = nil
- }
+
+ current = curMSI[thisSel]
+ default:
+ current = nil
+ }
+
+ // do we need to access the item of an array?
+ if index > -1 {
+ if array, ok := interSlice(current); ok {
+ if index < len(array) {
+ current = array[index]
+ } else {
+ current = nil
}
}
- if len(selSegs) > 1 {
- current = access(current, selSegs[1], value, isSet)
- }
+ }
+ if nextSel != "" {
+ current = access(current, nextSel, value, isSet)
}
return current
}
-// intFromInterface converts an interface object to the largest
-// representation of an unsigned integer using a type switch and
-// assertions
-func intFromInterface(selector interface{}) int {
- var value int
- switch selector.(type) {
- case int:
- value = selector.(int)
- case int8:
- value = int(selector.(int8))
- case int16:
- value = int(selector.(int16))
- case int32:
- value = int(selector.(int32))
- case int64:
- value = int(selector.(int64))
- case uint:
- value = int(selector.(uint))
- case uint8:
- value = int(selector.(uint8))
- case uint16:
- value = int(selector.(uint16))
- case uint32:
- value = int(selector.(uint32))
- case uint64:
- value = int(selector.(uint64))
- default:
- return 0
+func interSlice(slice interface{}) ([]interface{}, bool) {
+ if array, ok := slice.([]interface{}); ok {
+ return array, ok
+ }
+
+ s := reflect.ValueOf(slice)
+ if s.Kind() != reflect.Slice {
+ return nil, false
}
- return value
+
+ ret := make([]interface{}, s.Len())
+
+ for i := 0; i < s.Len(); i++ {
+ ret[i] = s.Index(i).Interface()
+ }
+
+ return ret, true
}
diff --git a/vendor/github.com/stretchr/objx/constants.go b/vendor/github.com/stretchr/objx/constants.go
deleted file mode 100644
index f9eb42a25..000000000
--- a/vendor/github.com/stretchr/objx/constants.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package objx
-
-const (
- // PathSeparator is the character used to separate the elements
- // of the keypath.
- //
- // For example, `location.address.city`
- PathSeparator string = "."
-
- // SignatureSeparator is the character that is used to
- // separate the Base64 string from the security signature.
- SignatureSeparator = "_"
-)
diff --git a/vendor/github.com/stretchr/objx/conversions.go b/vendor/github.com/stretchr/objx/conversions.go
index 5e020f310..080aa46e4 100644
--- a/vendor/github.com/stretchr/objx/conversions.go
+++ b/vendor/github.com/stretchr/objx/conversions.go
@@ -7,11 +7,51 @@ import (
"errors"
"fmt"
"net/url"
+ "strconv"
)
+// SignatureSeparator is the character that is used to
+// separate the Base64 string from the security signature.
+const SignatureSeparator = "_"
+
+// URLValuesSliceKeySuffix is the character that is used to
+// specify a suffic for slices parsed by URLValues.
+// If the suffix is set to "[i]", then the index of the slice
+// is used in place of i
+// Ex: Suffix "[]" would have the form a[]=b&a[]=c
+// OR Suffix "[i]" would have the form a[0]=b&a[1]=c
+// OR Suffix "" would have the form a=b&a=c
+var urlValuesSliceKeySuffix = "[]"
+
+const (
+ URLValuesSliceKeySuffixEmpty = ""
+ URLValuesSliceKeySuffixArray = "[]"
+ URLValuesSliceKeySuffixIndex = "[i]"
+)
+
+// SetURLValuesSliceKeySuffix sets the character that is used to
+// specify a suffic for slices parsed by URLValues.
+// If the suffix is set to "[i]", then the index of the slice
+// is used in place of i
+// Ex: Suffix "[]" would have the form a[]=b&a[]=c
+// OR Suffix "[i]" would have the form a[0]=b&a[1]=c
+// OR Suffix "" would have the form a=b&a=c
+func SetURLValuesSliceKeySuffix(s string) error {
+ if s == URLValuesSliceKeySuffixEmpty || s == URLValuesSliceKeySuffixArray || s == URLValuesSliceKeySuffixIndex {
+ urlValuesSliceKeySuffix = s
+ return nil
+ }
+
+ return errors.New("objx: Invalid URLValuesSliceKeySuffix provided.")
+}
+
// JSON converts the contained object to a JSON string
// representation
func (m Map) JSON() (string, error) {
+ for k, v := range m {
+ m[k] = cleanUp(v)
+ }
+
result, err := json.Marshal(m)
if err != nil {
err = errors.New("objx: JSON encode failed with: " + err.Error())
@@ -19,6 +59,63 @@ func (m Map) JSON() (string, error) {
return string(result), err
}
+func cleanUpInterfaceArray(in []interface{}) []interface{} {
+ result := make([]interface{}, len(in))
+ for i, v := range in {
+ result[i] = cleanUp(v)
+ }
+ return result
+}
+
+func cleanUpInterfaceMap(in map[interface{}]interface{}) Map {
+ result := Map{}
+ for k, v := range in {
+ result[fmt.Sprintf("%v", k)] = cleanUp(v)
+ }
+ return result
+}
+
+func cleanUpStringMap(in map[string]interface{}) Map {
+ result := Map{}
+ for k, v := range in {
+ result[k] = cleanUp(v)
+ }
+ return result
+}
+
+func cleanUpMSIArray(in []map[string]interface{}) []Map {
+ result := make([]Map, len(in))
+ for i, v := range in {
+ result[i] = cleanUpStringMap(v)
+ }
+ return result
+}
+
+func cleanUpMapArray(in []Map) []Map {
+ result := make([]Map, len(in))
+ for i, v := range in {
+ result[i] = cleanUpStringMap(v)
+ }
+ return result
+}
+
+func cleanUp(v interface{}) interface{} {
+ switch v := v.(type) {
+ case []interface{}:
+ return cleanUpInterfaceArray(v)
+ case []map[string]interface{}:
+ return cleanUpMSIArray(v)
+ case map[interface{}]interface{}:
+ return cleanUpInterfaceMap(v)
+ case Map:
+ return cleanUpStringMap(v)
+ case []Map:
+ return cleanUpMapArray(v)
+ default:
+ return v
+ }
+}
+
// MustJSON converts the contained object to a JSON string
// representation and panics if there is an error
func (m Map) MustJSON() string {
@@ -40,10 +137,7 @@ func (m Map) Base64() (string, error) {
}
encoder := base64.NewEncoder(base64.StdEncoding, &buf)
- _, err = encoder.Write([]byte(jsonData))
- if err != nil {
- return "", err
- }
+ _, _ = encoder.Write([]byte(jsonData))
_ = encoder.Close()
return buf.String(), nil
@@ -93,13 +187,91 @@ func (m Map) MustSignedBase64(key string) string {
// function requires that the wrapped object be a map[string]interface{}
func (m Map) URLValues() url.Values {
vals := make(url.Values)
- for k, v := range m {
- //TODO: can this be done without sprintf?
- vals.Set(k, fmt.Sprintf("%v", v))
- }
+
+ m.parseURLValues(m, vals, "")
+
return vals
}
+func (m Map) parseURLValues(queryMap Map, vals url.Values, key string) {
+ useSliceIndex := false
+ if urlValuesSliceKeySuffix == "[i]" {
+ useSliceIndex = true
+ }
+
+ for k, v := range queryMap {
+ val := &Value{data: v}
+ switch {
+ case val.IsObjxMap():
+ if key == "" {
+ m.parseURLValues(val.ObjxMap(), vals, k)
+ } else {
+ m.parseURLValues(val.ObjxMap(), vals, key+"["+k+"]")
+ }
+ case val.IsObjxMapSlice():
+ sliceKey := k
+ if key != "" {
+ sliceKey = key + "[" + k + "]"
+ }
+
+ if useSliceIndex {
+ for i, sv := range val.MustObjxMapSlice() {
+ sk := sliceKey + "[" + strconv.FormatInt(int64(i), 10) + "]"
+ m.parseURLValues(sv, vals, sk)
+ }
+ } else {
+ sliceKey = sliceKey + urlValuesSliceKeySuffix
+ for _, sv := range val.MustObjxMapSlice() {
+ m.parseURLValues(sv, vals, sliceKey)
+ }
+ }
+ case val.IsMSISlice():
+ sliceKey := k
+ if key != "" {
+ sliceKey = key + "[" + k + "]"
+ }
+
+ if useSliceIndex {
+ for i, sv := range val.MustMSISlice() {
+ sk := sliceKey + "[" + strconv.FormatInt(int64(i), 10) + "]"
+ m.parseURLValues(New(sv), vals, sk)
+ }
+ } else {
+ sliceKey = sliceKey + urlValuesSliceKeySuffix
+ for _, sv := range val.MustMSISlice() {
+ m.parseURLValues(New(sv), vals, sliceKey)
+ }
+ }
+ case val.IsStrSlice(), val.IsBoolSlice(),
+ val.IsFloat32Slice(), val.IsFloat64Slice(),
+ val.IsIntSlice(), val.IsInt8Slice(), val.IsInt16Slice(), val.IsInt32Slice(), val.IsInt64Slice(),
+ val.IsUintSlice(), val.IsUint8Slice(), val.IsUint16Slice(), val.IsUint32Slice(), val.IsUint64Slice():
+
+ sliceKey := k
+ if key != "" {
+ sliceKey = key + "[" + k + "]"
+ }
+
+ if useSliceIndex {
+ for i, sv := range val.StringSlice() {
+ sk := sliceKey + "[" + strconv.FormatInt(int64(i), 10) + "]"
+ vals.Set(sk, sv)
+ }
+ } else {
+ sliceKey = sliceKey + urlValuesSliceKeySuffix
+ vals[sliceKey] = val.StringSlice()
+ }
+
+ default:
+ if key == "" {
+ vals.Set(k, val.String())
+ } else {
+ vals.Set(key+"["+k+"]", val.String())
+ }
+ }
+ }
+}
+
// URLQuery gets an encoded URL query representing the given
// Obj. This function requires that the wrapped object be a
// map[string]interface{}
diff --git a/vendor/github.com/stretchr/objx/go.mod b/vendor/github.com/stretchr/objx/go.mod
new file mode 100644
index 000000000..31ec5a7d9
--- /dev/null
+++ b/vendor/github.com/stretchr/objx/go.mod
@@ -0,0 +1,8 @@
+module github.com/stretchr/objx
+
+go 1.12
+
+require (
+ github.com/davecgh/go-spew v1.1.1 // indirect
+ github.com/stretchr/testify v1.3.0
+)
diff --git a/vendor/github.com/stretchr/objx/go.sum b/vendor/github.com/stretchr/objx/go.sum
new file mode 100644
index 000000000..4f8984150
--- /dev/null
+++ b/vendor/github.com/stretchr/objx/go.sum
@@ -0,0 +1,8 @@
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
+github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
diff --git a/vendor/github.com/stretchr/objx/map.go b/vendor/github.com/stretchr/objx/map.go
index 406bc8926..95149c06a 100644
--- a/vendor/github.com/stretchr/objx/map.go
+++ b/vendor/github.com/stretchr/objx/map.go
@@ -97,12 +97,50 @@ func MustFromJSON(jsonString string) Map {
//
// Returns an error if the JSON is invalid.
func FromJSON(jsonString string) (Map, error) {
- var data interface{}
- err := json.Unmarshal([]byte(jsonString), &data)
+ var m Map
+ err := json.Unmarshal([]byte(jsonString), &m)
if err != nil {
return Nil, err
}
- return New(data), nil
+ m.tryConvertFloat64()
+ return m, nil
+}
+
+func (m Map) tryConvertFloat64() {
+ for k, v := range m {
+ switch v.(type) {
+ case float64:
+ f := v.(float64)
+ if float64(int(f)) == f {
+ m[k] = int(f)
+ }
+ case map[string]interface{}:
+ t := New(v)
+ t.tryConvertFloat64()
+ m[k] = t
+ case []interface{}:
+ m[k] = tryConvertFloat64InSlice(v.([]interface{}))
+ }
+ }
+}
+
+func tryConvertFloat64InSlice(s []interface{}) []interface{} {
+ for k, v := range s {
+ switch v.(type) {
+ case float64:
+ f := v.(float64)
+ if float64(int(f)) == f {
+ s[k] = int(f)
+ }
+ case map[string]interface{}:
+ t := New(v)
+ t.tryConvertFloat64()
+ s[k] = t
+ case []interface{}:
+ s[k] = tryConvertFloat64InSlice(v.([]interface{}))
+ }
+ }
+ return s
}
// FromBase64 creates a new Obj containing the data specified
diff --git a/vendor/github.com/stretchr/objx/type_specific.go b/vendor/github.com/stretchr/objx/type_specific.go
new file mode 100644
index 000000000..80f88d9fa
--- /dev/null
+++ b/vendor/github.com/stretchr/objx/type_specific.go
@@ -0,0 +1,346 @@
+package objx
+
+/*
+ MSI (map[string]interface{} and []map[string]interface{})
+*/
+
+// MSI gets the value as a map[string]interface{}, returns the optionalDefault
+// value or a system default object if the value is the wrong type.
+func (v *Value) MSI(optionalDefault ...map[string]interface{}) map[string]interface{} {
+ if s, ok := v.data.(map[string]interface{}); ok {
+ return s
+ }
+ if s, ok := v.data.(Map); ok {
+ return map[string]interface{}(s)
+ }
+ if len(optionalDefault) == 1 {
+ return optionalDefault[0]
+ }
+ return nil
+}
+
+// MustMSI gets the value as a map[string]interface{}.
+//
+// Panics if the object is not a map[string]interface{}.
+func (v *Value) MustMSI() map[string]interface{} {
+ if s, ok := v.data.(Map); ok {
+ return map[string]interface{}(s)
+ }
+ return v.data.(map[string]interface{})
+}
+
+// MSISlice gets the value as a []map[string]interface{}, returns the optionalDefault
+// value or nil if the value is not a []map[string]interface{}.
+func (v *Value) MSISlice(optionalDefault ...[]map[string]interface{}) []map[string]interface{} {
+ if s, ok := v.data.([]map[string]interface{}); ok {
+ return s
+ }
+
+ s := v.ObjxMapSlice()
+ if s == nil {
+ if len(optionalDefault) == 1 {
+ return optionalDefault[0]
+ }
+ return nil
+ }
+
+ result := make([]map[string]interface{}, len(s))
+ for i := range s {
+ result[i] = s[i].Value().MSI()
+ }
+ return result
+}
+
+// MustMSISlice gets the value as a []map[string]interface{}.
+//
+// Panics if the object is not a []map[string]interface{}.
+func (v *Value) MustMSISlice() []map[string]interface{} {
+ if s := v.MSISlice(); s != nil {
+ return s
+ }
+
+ return v.data.([]map[string]interface{})
+}
+
+// IsMSI gets whether the object contained is a map[string]interface{} or not.
+func (v *Value) IsMSI() bool {
+ _, ok := v.data.(map[string]interface{})
+ if !ok {
+ _, ok = v.data.(Map)
+ }
+ return ok
+}
+
+// IsMSISlice gets whether the object contained is a []map[string]interface{} or not.
+func (v *Value) IsMSISlice() bool {
+ _, ok := v.data.([]map[string]interface{})
+ if !ok {
+ _, ok = v.data.([]Map)
+ if !ok {
+ s, ok := v.data.([]interface{})
+ if ok {
+ for i := range s {
+ switch s[i].(type) {
+ case Map:
+ case map[string]interface{}:
+ default:
+ return false
+ }
+ }
+ return true
+ }
+ }
+ }
+ return ok
+}
+
+// EachMSI calls the specified callback for each object
+// in the []map[string]interface{}.
+//
+// Panics if the object is the wrong type.
+func (v *Value) EachMSI(callback func(int, map[string]interface{}) bool) *Value {
+ for index, val := range v.MustMSISlice() {
+ carryon := callback(index, val)
+ if !carryon {
+ break
+ }
+ }
+ return v
+}
+
+// WhereMSI uses the specified decider function to select items
+// from the []map[string]interface{}. The object contained in the result will contain
+// only the selected items.
+func (v *Value) WhereMSI(decider func(int, map[string]interface{}) bool) *Value {
+ var selected []map[string]interface{}
+ v.EachMSI(func(index int, val map[string]interface{}) bool {
+ shouldSelect := decider(index, val)
+ if !shouldSelect {
+ selected = append(selected, val)
+ }
+ return true
+ })
+ return &Value{data: selected}
+}
+
+// GroupMSI uses the specified grouper function to group the items
+// keyed by the return of the grouper. The object contained in the
+// result will contain a map[string][]map[string]interface{}.
+func (v *Value) GroupMSI(grouper func(int, map[string]interface{}) string) *Value {
+ groups := make(map[string][]map[string]interface{})
+ v.EachMSI(func(index int, val map[string]interface{}) bool {
+ group := grouper(index, val)
+ if _, ok := groups[group]; !ok {
+ groups[group] = make([]map[string]interface{}, 0)
+ }
+ groups[group] = append(groups[group], val)
+ return true
+ })
+ return &Value{data: groups}
+}
+
+// ReplaceMSI uses the specified function to replace each map[string]interface{}s
+// by iterating each item. The data in the returned result will be a
+// []map[string]interface{} containing the replaced items.
+func (v *Value) ReplaceMSI(replacer func(int, map[string]interface{}) map[string]interface{}) *Value {
+ arr := v.MustMSISlice()
+ replaced := make([]map[string]interface{}, len(arr))
+ v.EachMSI(func(index int, val map[string]interface{}) bool {
+ replaced[index] = replacer(index, val)
+ return true
+ })
+ return &Value{data: replaced}
+}
+
+// CollectMSI uses the specified collector function to collect a value
+// for each of the map[string]interface{}s in the slice. The data returned will be a
+// []interface{}.
+func (v *Value) CollectMSI(collector func(int, map[string]interface{}) interface{}) *Value {
+ arr := v.MustMSISlice()
+ collected := make([]interface{}, len(arr))
+ v.EachMSI(func(index int, val map[string]interface{}) bool {
+ collected[index] = collector(index, val)
+ return true
+ })
+ return &Value{data: collected}
+}
+
+/*
+ ObjxMap ((Map) and [](Map))
+*/
+
+// ObjxMap gets the value as a (Map), returns the optionalDefault
+// value or a system default object if the value is the wrong type.
+func (v *Value) ObjxMap(optionalDefault ...(Map)) Map {
+ if s, ok := v.data.((Map)); ok {
+ return s
+ }
+ if s, ok := v.data.(map[string]interface{}); ok {
+ return s
+ }
+ if len(optionalDefault) == 1 {
+ return optionalDefault[0]
+ }
+ return New(nil)
+}
+
+// MustObjxMap gets the value as a (Map).
+//
+// Panics if the object is not a (Map).
+func (v *Value) MustObjxMap() Map {
+ if s, ok := v.data.(map[string]interface{}); ok {
+ return s
+ }
+ return v.data.((Map))
+}
+
+// ObjxMapSlice gets the value as a [](Map), returns the optionalDefault
+// value or nil if the value is not a [](Map).
+func (v *Value) ObjxMapSlice(optionalDefault ...[](Map)) [](Map) {
+ if s, ok := v.data.([]Map); ok {
+ return s
+ }
+
+ if s, ok := v.data.([]map[string]interface{}); ok {
+ result := make([]Map, len(s))
+ for i := range s {
+ result[i] = s[i]
+ }
+ return result
+ }
+
+ s, ok := v.data.([]interface{})
+ if !ok {
+ if len(optionalDefault) == 1 {
+ return optionalDefault[0]
+ }
+ return nil
+ }
+
+ result := make([]Map, len(s))
+ for i := range s {
+ switch s[i].(type) {
+ case Map:
+ result[i] = s[i].(Map)
+ case map[string]interface{}:
+ result[i] = New(s[i])
+ default:
+ return nil
+ }
+ }
+ return result
+}
+
+// MustObjxMapSlice gets the value as a [](Map).
+//
+// Panics if the object is not a [](Map).
+func (v *Value) MustObjxMapSlice() [](Map) {
+ if s := v.ObjxMapSlice(); s != nil {
+ return s
+ }
+ return v.data.([](Map))
+}
+
+// IsObjxMap gets whether the object contained is a (Map) or not.
+func (v *Value) IsObjxMap() bool {
+ _, ok := v.data.((Map))
+ if !ok {
+ _, ok = v.data.(map[string]interface{})
+ }
+ return ok
+}
+
+// IsObjxMapSlice gets whether the object contained is a [](Map) or not.
+func (v *Value) IsObjxMapSlice() bool {
+ _, ok := v.data.([](Map))
+ if !ok {
+ _, ok = v.data.([]map[string]interface{})
+ if !ok {
+ s, ok := v.data.([]interface{})
+ if ok {
+ for i := range s {
+ switch s[i].(type) {
+ case Map:
+ case map[string]interface{}:
+ default:
+ return false
+ }
+ }
+ return true
+ }
+ }
+ }
+
+ return ok
+}
+
+// EachObjxMap calls the specified callback for each object
+// in the [](Map).
+//
+// Panics if the object is the wrong type.
+func (v *Value) EachObjxMap(callback func(int, Map) bool) *Value {
+ for index, val := range v.MustObjxMapSlice() {
+ carryon := callback(index, val)
+ if !carryon {
+ break
+ }
+ }
+ return v
+}
+
+// WhereObjxMap uses the specified decider function to select items
+// from the [](Map). The object contained in the result will contain
+// only the selected items.
+func (v *Value) WhereObjxMap(decider func(int, Map) bool) *Value {
+ var selected [](Map)
+ v.EachObjxMap(func(index int, val Map) bool {
+ shouldSelect := decider(index, val)
+ if !shouldSelect {
+ selected = append(selected, val)
+ }
+ return true
+ })
+ return &Value{data: selected}
+}
+
+// GroupObjxMap uses the specified grouper function to group the items
+// keyed by the return of the grouper. The object contained in the
+// result will contain a map[string][](Map).
+func (v *Value) GroupObjxMap(grouper func(int, Map) string) *Value {
+ groups := make(map[string][](Map))
+ v.EachObjxMap(func(index int, val Map) bool {
+ group := grouper(index, val)
+ if _, ok := groups[group]; !ok {
+ groups[group] = make([](Map), 0)
+ }
+ groups[group] = append(groups[group], val)
+ return true
+ })
+ return &Value{data: groups}
+}
+
+// ReplaceObjxMap uses the specified function to replace each (Map)s
+// by iterating each item. The data in the returned result will be a
+// [](Map) containing the replaced items.
+func (v *Value) ReplaceObjxMap(replacer func(int, Map) Map) *Value {
+ arr := v.MustObjxMapSlice()
+ replaced := make([](Map), len(arr))
+ v.EachObjxMap(func(index int, val Map) bool {
+ replaced[index] = replacer(index, val)
+ return true
+ })
+ return &Value{data: replaced}
+}
+
+// CollectObjxMap uses the specified collector function to collect a value
+// for each of the (Map)s in the slice. The data returned will be a
+// []interface{}.
+func (v *Value) CollectObjxMap(collector func(int, Map) interface{}) *Value {
+ arr := v.MustObjxMapSlice()
+ collected := make([]interface{}, len(arr))
+ v.EachObjxMap(func(index int, val Map) bool {
+ collected[index] = collector(index, val)
+ return true
+ })
+ return &Value{data: collected}
+}
diff --git a/vendor/github.com/stretchr/objx/type_specific_codegen.go b/vendor/github.com/stretchr/objx/type_specific_codegen.go
index 202a91f8c..9859b407f 100644
--- a/vendor/github.com/stretchr/objx/type_specific_codegen.go
+++ b/vendor/github.com/stretchr/objx/type_specific_codegen.go
@@ -1,7 +1,7 @@
package objx
/*
- Inter (interface{} and []interface{})
+ Inter (interface{} and []interface{})
*/
// Inter gets the value as a interface{}, returns the optionalDefault
@@ -126,257 +126,7 @@ func (v *Value) CollectInter(collector func(int, interface{}) interface{}) *Valu
}
/*
- MSI (map[string]interface{} and []map[string]interface{})
-*/
-
-// MSI gets the value as a map[string]interface{}, returns the optionalDefault
-// value or a system default object if the value is the wrong type.
-func (v *Value) MSI(optionalDefault ...map[string]interface{}) map[string]interface{} {
- if s, ok := v.data.(map[string]interface{}); ok {
- return s
- }
- if len(optionalDefault) == 1 {
- return optionalDefault[0]
- }
- return nil
-}
-
-// MustMSI gets the value as a map[string]interface{}.
-//
-// Panics if the object is not a map[string]interface{}.
-func (v *Value) MustMSI() map[string]interface{} {
- return v.data.(map[string]interface{})
-}
-
-// MSISlice gets the value as a []map[string]interface{}, returns the optionalDefault
-// value or nil if the value is not a []map[string]interface{}.
-func (v *Value) MSISlice(optionalDefault ...[]map[string]interface{}) []map[string]interface{} {
- if s, ok := v.data.([]map[string]interface{}); ok {
- return s
- }
- if len(optionalDefault) == 1 {
- return optionalDefault[0]
- }
- return nil
-}
-
-// MustMSISlice gets the value as a []map[string]interface{}.
-//
-// Panics if the object is not a []map[string]interface{}.
-func (v *Value) MustMSISlice() []map[string]interface{} {
- return v.data.([]map[string]interface{})
-}
-
-// IsMSI gets whether the object contained is a map[string]interface{} or not.
-func (v *Value) IsMSI() bool {
- _, ok := v.data.(map[string]interface{})
- return ok
-}
-
-// IsMSISlice gets whether the object contained is a []map[string]interface{} or not.
-func (v *Value) IsMSISlice() bool {
- _, ok := v.data.([]map[string]interface{})
- return ok
-}
-
-// EachMSI calls the specified callback for each object
-// in the []map[string]interface{}.
-//
-// Panics if the object is the wrong type.
-func (v *Value) EachMSI(callback func(int, map[string]interface{}) bool) *Value {
- for index, val := range v.MustMSISlice() {
- carryon := callback(index, val)
- if !carryon {
- break
- }
- }
- return v
-}
-
-// WhereMSI uses the specified decider function to select items
-// from the []map[string]interface{}. The object contained in the result will contain
-// only the selected items.
-func (v *Value) WhereMSI(decider func(int, map[string]interface{}) bool) *Value {
- var selected []map[string]interface{}
- v.EachMSI(func(index int, val map[string]interface{}) bool {
- shouldSelect := decider(index, val)
- if !shouldSelect {
- selected = append(selected, val)
- }
- return true
- })
- return &Value{data: selected}
-}
-
-// GroupMSI uses the specified grouper function to group the items
-// keyed by the return of the grouper. The object contained in the
-// result will contain a map[string][]map[string]interface{}.
-func (v *Value) GroupMSI(grouper func(int, map[string]interface{}) string) *Value {
- groups := make(map[string][]map[string]interface{})
- v.EachMSI(func(index int, val map[string]interface{}) bool {
- group := grouper(index, val)
- if _, ok := groups[group]; !ok {
- groups[group] = make([]map[string]interface{}, 0)
- }
- groups[group] = append(groups[group], val)
- return true
- })
- return &Value{data: groups}
-}
-
-// ReplaceMSI uses the specified function to replace each map[string]interface{}s
-// by iterating each item. The data in the returned result will be a
-// []map[string]interface{} containing the replaced items.
-func (v *Value) ReplaceMSI(replacer func(int, map[string]interface{}) map[string]interface{}) *Value {
- arr := v.MustMSISlice()
- replaced := make([]map[string]interface{}, len(arr))
- v.EachMSI(func(index int, val map[string]interface{}) bool {
- replaced[index] = replacer(index, val)
- return true
- })
- return &Value{data: replaced}
-}
-
-// CollectMSI uses the specified collector function to collect a value
-// for each of the map[string]interface{}s in the slice. The data returned will be a
-// []interface{}.
-func (v *Value) CollectMSI(collector func(int, map[string]interface{}) interface{}) *Value {
- arr := v.MustMSISlice()
- collected := make([]interface{}, len(arr))
- v.EachMSI(func(index int, val map[string]interface{}) bool {
- collected[index] = collector(index, val)
- return true
- })
- return &Value{data: collected}
-}
-
-/*
- ObjxMap ((Map) and [](Map))
-*/
-
-// ObjxMap gets the value as a (Map), returns the optionalDefault
-// value or a system default object if the value is the wrong type.
-func (v *Value) ObjxMap(optionalDefault ...(Map)) Map {
- if s, ok := v.data.((Map)); ok {
- return s
- }
- if len(optionalDefault) == 1 {
- return optionalDefault[0]
- }
- return New(nil)
-}
-
-// MustObjxMap gets the value as a (Map).
-//
-// Panics if the object is not a (Map).
-func (v *Value) MustObjxMap() Map {
- return v.data.((Map))
-}
-
-// ObjxMapSlice gets the value as a [](Map), returns the optionalDefault
-// value or nil if the value is not a [](Map).
-func (v *Value) ObjxMapSlice(optionalDefault ...[](Map)) [](Map) {
- if s, ok := v.data.([](Map)); ok {
- return s
- }
- if len(optionalDefault) == 1 {
- return optionalDefault[0]
- }
- return nil
-}
-
-// MustObjxMapSlice gets the value as a [](Map).
-//
-// Panics if the object is not a [](Map).
-func (v *Value) MustObjxMapSlice() [](Map) {
- return v.data.([](Map))
-}
-
-// IsObjxMap gets whether the object contained is a (Map) or not.
-func (v *Value) IsObjxMap() bool {
- _, ok := v.data.((Map))
- return ok
-}
-
-// IsObjxMapSlice gets whether the object contained is a [](Map) or not.
-func (v *Value) IsObjxMapSlice() bool {
- _, ok := v.data.([](Map))
- return ok
-}
-
-// EachObjxMap calls the specified callback for each object
-// in the [](Map).
-//
-// Panics if the object is the wrong type.
-func (v *Value) EachObjxMap(callback func(int, Map) bool) *Value {
- for index, val := range v.MustObjxMapSlice() {
- carryon := callback(index, val)
- if !carryon {
- break
- }
- }
- return v
-}
-
-// WhereObjxMap uses the specified decider function to select items
-// from the [](Map). The object contained in the result will contain
-// only the selected items.
-func (v *Value) WhereObjxMap(decider func(int, Map) bool) *Value {
- var selected [](Map)
- v.EachObjxMap(func(index int, val Map) bool {
- shouldSelect := decider(index, val)
- if !shouldSelect {
- selected = append(selected, val)
- }
- return true
- })
- return &Value{data: selected}
-}
-
-// GroupObjxMap uses the specified grouper function to group the items
-// keyed by the return of the grouper. The object contained in the
-// result will contain a map[string][](Map).
-func (v *Value) GroupObjxMap(grouper func(int, Map) string) *Value {
- groups := make(map[string][](Map))
- v.EachObjxMap(func(index int, val Map) bool {
- group := grouper(index, val)
- if _, ok := groups[group]; !ok {
- groups[group] = make([](Map), 0)
- }
- groups[group] = append(groups[group], val)
- return true
- })
- return &Value{data: groups}
-}
-
-// ReplaceObjxMap uses the specified function to replace each (Map)s
-// by iterating each item. The data in the returned result will be a
-// [](Map) containing the replaced items.
-func (v *Value) ReplaceObjxMap(replacer func(int, Map) Map) *Value {
- arr := v.MustObjxMapSlice()
- replaced := make([](Map), len(arr))
- v.EachObjxMap(func(index int, val Map) bool {
- replaced[index] = replacer(index, val)
- return true
- })
- return &Value{data: replaced}
-}
-
-// CollectObjxMap uses the specified collector function to collect a value
-// for each of the (Map)s in the slice. The data returned will be a
-// []interface{}.
-func (v *Value) CollectObjxMap(collector func(int, Map) interface{}) *Value {
- arr := v.MustObjxMapSlice()
- collected := make([]interface{}, len(arr))
- v.EachObjxMap(func(index int, val Map) bool {
- collected[index] = collector(index, val)
- return true
- })
- return &Value{data: collected}
-}
-
-/*
- Bool (bool and []bool)
+ Bool (bool and []bool)
*/
// Bool gets the value as a bool, returns the optionalDefault
@@ -501,7 +251,7 @@ func (v *Value) CollectBool(collector func(int, bool) interface{}) *Value {
}
/*
- Str (string and []string)
+ Str (string and []string)
*/
// Str gets the value as a string, returns the optionalDefault
@@ -626,7 +376,7 @@ func (v *Value) CollectStr(collector func(int, string) interface{}) *Value {
}
/*
- Int (int and []int)
+ Int (int and []int)
*/
// Int gets the value as a int, returns the optionalDefault
@@ -751,7 +501,7 @@ func (v *Value) CollectInt(collector func(int, int) interface{}) *Value {
}
/*
- Int8 (int8 and []int8)
+ Int8 (int8 and []int8)
*/
// Int8 gets the value as a int8, returns the optionalDefault
@@ -876,7 +626,7 @@ func (v *Value) CollectInt8(collector func(int, int8) interface{}) *Value {
}
/*
- Int16 (int16 and []int16)
+ Int16 (int16 and []int16)
*/
// Int16 gets the value as a int16, returns the optionalDefault
@@ -1001,7 +751,7 @@ func (v *Value) CollectInt16(collector func(int, int16) interface{}) *Value {
}
/*
- Int32 (int32 and []int32)
+ Int32 (int32 and []int32)
*/
// Int32 gets the value as a int32, returns the optionalDefault
@@ -1126,7 +876,7 @@ func (v *Value) CollectInt32(collector func(int, int32) interface{}) *Value {
}
/*
- Int64 (int64 and []int64)
+ Int64 (int64 and []int64)
*/
// Int64 gets the value as a int64, returns the optionalDefault
@@ -1251,7 +1001,7 @@ func (v *Value) CollectInt64(collector func(int, int64) interface{}) *Value {
}
/*
- Uint (uint and []uint)
+ Uint (uint and []uint)
*/
// Uint gets the value as a uint, returns the optionalDefault
@@ -1376,7 +1126,7 @@ func (v *Value) CollectUint(collector func(int, uint) interface{}) *Value {
}
/*
- Uint8 (uint8 and []uint8)
+ Uint8 (uint8 and []uint8)
*/
// Uint8 gets the value as a uint8, returns the optionalDefault
@@ -1501,7 +1251,7 @@ func (v *Value) CollectUint8(collector func(int, uint8) interface{}) *Value {
}
/*
- Uint16 (uint16 and []uint16)
+ Uint16 (uint16 and []uint16)
*/
// Uint16 gets the value as a uint16, returns the optionalDefault
@@ -1626,7 +1376,7 @@ func (v *Value) CollectUint16(collector func(int, uint16) interface{}) *Value {
}
/*
- Uint32 (uint32 and []uint32)
+ Uint32 (uint32 and []uint32)
*/
// Uint32 gets the value as a uint32, returns the optionalDefault
@@ -1751,7 +1501,7 @@ func (v *Value) CollectUint32(collector func(int, uint32) interface{}) *Value {
}
/*
- Uint64 (uint64 and []uint64)
+ Uint64 (uint64 and []uint64)
*/
// Uint64 gets the value as a uint64, returns the optionalDefault
@@ -1876,7 +1626,7 @@ func (v *Value) CollectUint64(collector func(int, uint64) interface{}) *Value {
}
/*
- Uintptr (uintptr and []uintptr)
+ Uintptr (uintptr and []uintptr)
*/
// Uintptr gets the value as a uintptr, returns the optionalDefault
@@ -2001,7 +1751,7 @@ func (v *Value) CollectUintptr(collector func(int, uintptr) interface{}) *Value
}
/*
- Float32 (float32 and []float32)
+ Float32 (float32 and []float32)
*/
// Float32 gets the value as a float32, returns the optionalDefault
@@ -2126,7 +1876,7 @@ func (v *Value) CollectFloat32(collector func(int, float32) interface{}) *Value
}
/*
- Float64 (float64 and []float64)
+ Float64 (float64 and []float64)
*/
// Float64 gets the value as a float64, returns the optionalDefault
@@ -2251,7 +2001,7 @@ func (v *Value) CollectFloat64(collector func(int, float64) interface{}) *Value
}
/*
- Complex64 (complex64 and []complex64)
+ Complex64 (complex64 and []complex64)
*/
// Complex64 gets the value as a complex64, returns the optionalDefault
@@ -2376,7 +2126,7 @@ func (v *Value) CollectComplex64(collector func(int, complex64) interface{}) *Va
}
/*
- Complex128 (complex128 and []complex128)
+ Complex128 (complex128 and []complex128)
*/
// Complex128 gets the value as a complex128, returns the optionalDefault
diff --git a/vendor/github.com/stretchr/objx/value.go b/vendor/github.com/stretchr/objx/value.go
index e4b4a1433..4e5f9b77e 100644
--- a/vendor/github.com/stretchr/objx/value.go
+++ b/vendor/github.com/stretchr/objx/value.go
@@ -20,6 +20,8 @@ func (v *Value) Data() interface{} {
// String returns the value always as a string
func (v *Value) String() string {
switch {
+ case v.IsNil():
+ return ""
case v.IsStr():
return v.Str()
case v.IsBool():
@@ -51,3 +53,107 @@ func (v *Value) String() string {
}
return fmt.Sprintf("%#v", v.Data())
}
+
+// StringSlice returns the value always as a []string
+func (v *Value) StringSlice(optionalDefault ...[]string) []string {
+ switch {
+ case v.IsStrSlice():
+ return v.MustStrSlice()
+ case v.IsBoolSlice():
+ slice := v.MustBoolSlice()
+ vals := make([]string, len(slice))
+ for i, iv := range slice {
+ vals[i] = strconv.FormatBool(iv)
+ }
+ return vals
+ case v.IsFloat32Slice():
+ slice := v.MustFloat32Slice()
+ vals := make([]string, len(slice))
+ for i, iv := range slice {
+ vals[i] = strconv.FormatFloat(float64(iv), 'f', -1, 32)
+ }
+ return vals
+ case v.IsFloat64Slice():
+ slice := v.MustFloat64Slice()
+ vals := make([]string, len(slice))
+ for i, iv := range slice {
+ vals[i] = strconv.FormatFloat(iv, 'f', -1, 64)
+ }
+ return vals
+ case v.IsIntSlice():
+ slice := v.MustIntSlice()
+ vals := make([]string, len(slice))
+ for i, iv := range slice {
+ vals[i] = strconv.FormatInt(int64(iv), 10)
+ }
+ return vals
+ case v.IsInt8Slice():
+ slice := v.MustInt8Slice()
+ vals := make([]string, len(slice))
+ for i, iv := range slice {
+ vals[i] = strconv.FormatInt(int64(iv), 10)
+ }
+ return vals
+ case v.IsInt16Slice():
+ slice := v.MustInt16Slice()
+ vals := make([]string, len(slice))
+ for i, iv := range slice {
+ vals[i] = strconv.FormatInt(int64(iv), 10)
+ }
+ return vals
+ case v.IsInt32Slice():
+ slice := v.MustInt32Slice()
+ vals := make([]string, len(slice))
+ for i, iv := range slice {
+ vals[i] = strconv.FormatInt(int64(iv), 10)
+ }
+ return vals
+ case v.IsInt64Slice():
+ slice := v.MustInt64Slice()
+ vals := make([]string, len(slice))
+ for i, iv := range slice {
+ vals[i] = strconv.FormatInt(iv, 10)
+ }
+ return vals
+ case v.IsUintSlice():
+ slice := v.MustUintSlice()
+ vals := make([]string, len(slice))
+ for i, iv := range slice {
+ vals[i] = strconv.FormatUint(uint64(iv), 10)
+ }
+ return vals
+ case v.IsUint8Slice():
+ slice := v.MustUint8Slice()
+ vals := make([]string, len(slice))
+ for i, iv := range slice {
+ vals[i] = strconv.FormatUint(uint64(iv), 10)
+ }
+ return vals
+ case v.IsUint16Slice():
+ slice := v.MustUint16Slice()
+ vals := make([]string, len(slice))
+ for i, iv := range slice {
+ vals[i] = strconv.FormatUint(uint64(iv), 10)
+ }
+ return vals
+ case v.IsUint32Slice():
+ slice := v.MustUint32Slice()
+ vals := make([]string, len(slice))
+ for i, iv := range slice {
+ vals[i] = strconv.FormatUint(uint64(iv), 10)
+ }
+ return vals
+ case v.IsUint64Slice():
+ slice := v.MustUint64Slice()
+ vals := make([]string, len(slice))
+ for i, iv := range slice {
+ vals[i] = strconv.FormatUint(iv, 10)
+ }
+ return vals
+ }
+ if len(optionalDefault) == 1 {
+ return optionalDefault[0]
+ }
+
+ return []string{}
+}