summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/stretchr/objx/map.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-06-21 13:10:40 -0700
committerHarrison Healey <harrisonmhealey@gmail.com>2018-06-21 16:10:40 -0400
commit8526739066ccb00ccd24b74650a7d7b284442985 (patch)
tree282512ae2ad95c98a9ca82de304a410b6b56685c /vendor/github.com/stretchr/objx/map.go
parenta59ccaa8b3844895dde3980e6224fef46ff4a1c8 (diff)
downloadchat-8526739066ccb00ccd24b74650a7d7b284442985.tar.gz
chat-8526739066ccb00ccd24b74650a7d7b284442985.tar.bz2
chat-8526739066ccb00ccd24b74650a7d7b284442985.zip
MM-10934 Update server dependencies. (#8981)
* Changing throttled import path. * Upgrading dependencies.
Diffstat (limited to 'vendor/github.com/stretchr/objx/map.go')
-rw-r--r--vendor/github.com/stretchr/objx/map.go19
1 files changed, 8 insertions, 11 deletions
diff --git a/vendor/github.com/stretchr/objx/map.go b/vendor/github.com/stretchr/objx/map.go
index 7e9389a20..406bc8926 100644
--- a/vendor/github.com/stretchr/objx/map.go
+++ b/vendor/github.com/stretchr/objx/map.go
@@ -47,9 +47,8 @@ func New(data interface{}) Map {
//
// The arguments follow a key, value pattern.
//
-// Panics
//
-// Panics if any key argument is non-string or if there are an odd number of arguments.
+// Returns nil if any key argument is non-string or if there are an odd number of arguments.
//
// Example
//
@@ -58,14 +57,13 @@ func New(data interface{}) Map {
// m := objx.MSI("name", "Mat", "age", 29, "subobj", objx.MSI("active", true))
//
// // creates an Map equivalent to
-// m := objx.New(map[string]interface{}{"name": "Mat", "age": 29, "subobj": map[string]interface{}{"active": true}})
+// m := objx.Map{"name": "Mat", "age": 29, "subobj": objx.Map{"active": true}}
func MSI(keyAndValuePairs ...interface{}) Map {
- newMap := make(map[string]interface{})
+ newMap := Map{}
keyAndValuePairsLen := len(keyAndValuePairs)
if keyAndValuePairsLen%2 != 0 {
- panic("objx: MSI must have an even number of arguments following the 'key, value' pattern.")
+ return nil
}
-
for i := 0; i < keyAndValuePairsLen; i = i + 2 {
key := keyAndValuePairs[i]
value := keyAndValuePairs[i+1]
@@ -73,11 +71,11 @@ func MSI(keyAndValuePairs ...interface{}) Map {
// make sure the key is a string
keyString, keyStringOK := key.(string)
if !keyStringOK {
- panic("objx: MSI must follow 'string, interface{}' pattern. " + keyString + " is not a valid key.")
+ return nil
}
newMap[keyString] = value
}
- return New(newMap)
+ return newMap
}
// ****** Conversion Constructors
@@ -170,12 +168,11 @@ func FromURLQuery(query string) (Map, error) {
if err != nil {
return nil, err
}
-
- m := make(map[string]interface{})
+ m := Map{}
for k, vals := range vals {
m[k] = vals[0]
}
- return New(m), nil
+ return m, nil
}
// MustFromURLQuery generates a new Obj by parsing the specified