You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
268 B
13 lines
268 B
3 years ago
|
package util
|
||
|
|
||
|
// Returns found key (int) in provided map by value (string);
|
||
|
// If key does not exist in map - returns -1
|
||
|
func GetKey(mp map[int]string, givenValue string) int {
|
||
|
for key, value := range mp {
|
||
|
if value == givenValue {
|
||
|
return key
|
||
|
}
|
||
|
}
|
||
|
return -1
|
||
|
}
|