From ebe40d560cdcd16cd5f9e87e9dac8791ec1ff7b3 Mon Sep 17 00:00:00 2001 From: Michael Bolot Date: Wed, 21 Feb 2024 12:19:50 -0600 Subject: [PATCH] Adding wrapper for GetValue Adds a wrapper for GetValue so that the new function doesn't result in a breaking change according to semver. --- pkg/data/values.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/data/values.go b/pkg/data/values.go index a0f07f42..61ca9e69 100644 --- a/pkg/data/values.go +++ b/pkg/data/values.go @@ -28,12 +28,18 @@ func GetValueN(data map[string]interface{}, keys ...string) interface{} { return val } -// GetValue retrieves a value from the provided collection, which must be a map[string]interface or a []interface. +// GetValue works the same as GetValueFromAny. Kept this way to avoid breaking changes with the previous interface, +// GetValueFromAny should be used directly in most cases. +func GetValue(data map[string]interface{}, keys ...string) (interface{}, bool) { + return GetValueFromAny(data, keys...) +} + +// GetValueFromAny retrieves a value from the provided collection, which must be a map[string]interface or a []interface. // Keys are always strings. // For a map, a key denotes the key in the map whose value we want to retrieve. // For the slice, it denotes the index (starting at 0) of the value we want to retrieve. // Returns the retrieved value (if any) and a bool indicating if the value was found. -func GetValue(data interface{}, keys ...string) (interface{}, bool) { +func GetValueFromAny(data interface{}, keys ...string) (interface{}, bool) { for i, key := range keys { if i == len(keys)-1 { if dataMap, ok := data.(map[string]interface{}); ok {