mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-07-17 02:53:12 -04:00
Bumps [github.com/open-policy-agent/opa](https://github.com/open-policy-agent/opa) from 1.4.2 to 1.5.0. - [Release notes](https://github.com/open-policy-agent/opa/releases) - [Changelog](https://github.com/open-policy-agent/opa/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-policy-agent/opa/compare/v1.4.2...v1.5.0) --- updated-dependencies: - dependency-name: github.com/open-policy-agent/opa dependency-version: 1.5.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
32 lines
712 B
Go
32 lines
712 B
Go
// Copyright 2020 The OPA Authors. All rights reserved.
|
|
// Use of this source code is governed by an Apache2
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package deepcopy
|
|
|
|
// DeepCopy performs a recursive deep copy for nested slices/maps and
|
|
// returns the copied object. Supports []any
|
|
// and map[string]any only
|
|
func DeepCopy(val any) any {
|
|
switch val := val.(type) {
|
|
case []any:
|
|
cpy := make([]any, len(val))
|
|
for i := range cpy {
|
|
cpy[i] = DeepCopy(val[i])
|
|
}
|
|
return cpy
|
|
case map[string]any:
|
|
return Map(val)
|
|
default:
|
|
return val
|
|
}
|
|
}
|
|
|
|
func Map(val map[string]any) map[string]any {
|
|
cpy := make(map[string]any, len(val))
|
|
for k := range val {
|
|
cpy[k] = DeepCopy(val[k])
|
|
}
|
|
return cpy
|
|
}
|