summaryrefslogtreecommitdiff
path: root/go/vendor/github.com/stretchr/objx/mutations.go
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2019-08-19 05:02:05 +0000
committerAsh McKenzie <amckenzie@gitlab.com>2019-08-19 05:02:05 +0000
commit256c97066bb7838d43798b6760d3acbb82c44263 (patch)
treea11de1a5bb9a3c27bcd6c9b31c0663bd91c5c8c8 /go/vendor/github.com/stretchr/objx/mutations.go
parent81f5854513a527c3a00398e91930a12ebad70272 (diff)
parent4d330cb1dd0fa2d6470d459fc33a987e8f550887 (diff)
downloadgitlab-shell-256c97066bb7838d43798b6760d3acbb82c44263.tar.gz
Merge branch 'jv-go-mod' into 'master'
Use go mod See merge request gitlab-org/gitlab-shell!323
Diffstat (limited to 'go/vendor/github.com/stretchr/objx/mutations.go')
-rw-r--r--go/vendor/github.com/stretchr/objx/mutations.go77
1 files changed, 0 insertions, 77 deletions
diff --git a/go/vendor/github.com/stretchr/objx/mutations.go b/go/vendor/github.com/stretchr/objx/mutations.go
deleted file mode 100644
index c3400a3..0000000
--- a/go/vendor/github.com/stretchr/objx/mutations.go
+++ /dev/null
@@ -1,77 +0,0 @@
-package objx
-
-// Exclude returns a new Map with the keys in the specified []string
-// excluded.
-func (m Map) Exclude(exclude []string) Map {
- excluded := make(Map)
- for k, v := range m {
- if !contains(exclude, k) {
- excluded[k] = v
- }
- }
- return excluded
-}
-
-// Copy creates a shallow copy of the Obj.
-func (m Map) Copy() Map {
- copied := Map{}
- for k, v := range m {
- copied[k] = v
- }
- return copied
-}
-
-// Merge blends the specified map with a copy of this map and returns the result.
-//
-// Keys that appear in both will be selected from the specified map.
-// This method requires that the wrapped object be a map[string]interface{}
-func (m Map) Merge(merge Map) Map {
- return m.Copy().MergeHere(merge)
-}
-
-// MergeHere blends the specified map with this map and returns the current map.
-//
-// Keys that appear in both will be selected from the specified map. The original map
-// will be modified. This method requires that
-// the wrapped object be a map[string]interface{}
-func (m Map) MergeHere(merge Map) Map {
- for k, v := range merge {
- m[k] = v
- }
- return m
-}
-
-// Transform builds a new Obj giving the transformer a chance
-// to change the keys and values as it goes. This method requires that
-// the wrapped object be a map[string]interface{}
-func (m Map) Transform(transformer func(key string, value interface{}) (string, interface{})) Map {
- newMap := Map{}
- for k, v := range m {
- modifiedKey, modifiedVal := transformer(k, v)
- newMap[modifiedKey] = modifiedVal
- }
- return newMap
-}
-
-// TransformKeys builds a new map using the specified key mapping.
-//
-// Unspecified keys will be unaltered.
-// This method requires that the wrapped object be a map[string]interface{}
-func (m Map) TransformKeys(mapping map[string]string) Map {
- return m.Transform(func(key string, value interface{}) (string, interface{}) {
- if newKey, ok := mapping[key]; ok {
- return newKey, value
- }
- return key, value
- })
-}
-
-// Checks if a string slice contains a string
-func contains(s []string, e string) bool {
- for _, a := range s {
- if a == e {
- return true
- }
- }
- return false
-}