mirror of
https://gitee.com/johng/gf.git
synced 2024-12-04 21:28:22 +08:00
27 lines
753 B
Go
27 lines
753 B
Go
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
|
//
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
// If a copy of the MIT was not distributed with this file,
|
|
// You can obtain one at https://github.com/gogf/gf.
|
|
|
|
package utils
|
|
|
|
// MapPossibleItemByKey tries to find the possible key-value pair for given key ignoring cases and symbols.
|
|
//
|
|
// Note that this function might be of low performance.
|
|
func MapPossibleItemByKey(data map[string]interface{}, key string) (foundKey string, foundValue interface{}) {
|
|
if len(data) == 0 {
|
|
return
|
|
}
|
|
if v, ok := data[key]; ok {
|
|
return key, v
|
|
}
|
|
// Loop checking.
|
|
for k, v := range data {
|
|
if EqualFoldWithoutChars(k, key) {
|
|
return k, v
|
|
}
|
|
}
|
|
return "", nil
|
|
}
|