Answers for "how to make a map in golang"

Go
1

golang map

package main
import "fmt"

func main() {

  object := map[string]string{
    "name": "john doe",
  }
  
  arrayObject := []map[string]string{
    map[string]string{ "name": "john doe"},
    map[string]string{"name": "jane doe"},
  }

  usingMake := make(map[string] string)
  usingMake["name"] = "max cavalera"
  
  fmt.Printf("this is object %v \n", object)
  fmt.Printf("this is array object %v \n", arrayObject)
  fmt.Printf("using make method %v \n", usingMake)
}
Posted by: Guest on March-30-2022

Browse Popular Code Answers by Language