How to add key value pair to map in Go

1 Answer

0 votes
package main
  
import "fmt"
  
func main() {
    var mp = map[string]int{"go":35,"php":4, "c++":120}
     
    fmt.Println(mp)
    
    mp["python"] = 8372
     
    fmt.Println(mp)
}
  
  
  
/*
run:
  
map[c++:120 go:35 php:4]
map[c++:120 go:35 php:4 python:8372]
  
*/

 



answered Nov 4, 2020 by avibootz

Related questions

1 answer 199 views
1 answer 245 views
1 answer 244 views
1 answer 217 views
3 answers 578 views
...