How to create Map using the make function in Go?
A map value can also be initialized using the
make
function.
Example
package main
import "fmt"
func main() {
var employee = make(map[string]int)
employee["Mark"] = 10
employee["Sandy"] = 20
fmt.Println(employee)
employeeList := make(map[string]int)
employeeList["Mark"] = 10
employeeList["Sandy"] = 20
fmt.Println(employeeList)
}
Output
map[Mark:10 Sandy:20]
map[Sandy:20 Mark:10]
Most Helpful This Week
Find out how many logical processors used by current process
Regular expression to validate the date format in "dd/mm/yyyy"
How to get the current date and time with timestamp in local and other timezones ?
How to set, get, and list environment variables?
Golang download image from given URL
Print index and element or data from Array, Slice and Map