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

3 answers 403 views
1 answer 119 views
1 answer 146 views
1 answer 151 views
1 answer 123 views
1 answer 29 views
...