Golang ProgramsGolang Programs

How to copy a map to another map?

To copy a map content need to execute a for loop and fetch the index value 1 by 1 with element and assign it to another map. Below is a short example.
package main

import (
func main() {	
	map1 := map[string]int{	
	map2 := map[string]int{}		
	/* Copy Content from Map1 to Map2*/
	for index,element := range map1{		
		 map2[index] = element
	for index,element := range map2{
C:\golang\codes>go run example.go
x => 1
y => 2