How to remove an element from map by value in Go

1 Answer

0 votes
package main
   
import (
    "fmt"
)
   
func main() {
    mp := map[string]int{"go":14, "php":3, "c++":876}
    val := "php";
    
    fmt.Println(mp)
     
    delete(mp, val) 
 
    fmt.Println(mp)
} 
 
    
  
/*
run:
   
map[c++:876 go:14 php:3]
map[c++:876 go:14]

*/

 



answered Aug 17, 2020 by avibootz

Related questions

1 answer 162 views
2 answers 209 views
1 answer 153 views
153 views asked Mar 15, 2020 by avibootz
1 answer 172 views
1 answer 161 views
2 answers 105 views
1 answer 19 views
...