mirror of
https://github.com/jefferyjob/go-easy-utils.git
synced 2025-10-28 01:12:15 +08:00
filename rename And unit test cover
This commit is contained in:
17
mapUtil/map_exists.go
Normal file
17
mapUtil/map_exists.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package mapUtil
|
||||
|
||||
// MapValueExists 判断map中的value是否存在
|
||||
func MapValueExists(m map[string]interface{}, value interface{}) bool {
|
||||
for _, v := range m {
|
||||
if v == value {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// MapKeyExists 判断map中的key是否存在
|
||||
func MapKeyExists(m map[string]interface{}, key string) bool {
|
||||
_, exists := m[key]
|
||||
return exists
|
||||
}
|
||||
Reference in New Issue
Block a user