In this program, we will create a simple map to store country code using the make() function. Then we create a copy of the map and print both maps on the console screen.
In the above program, we declare the package main. The main package is used to tell the Go language compiler that the package must be compiled and produced the executable file. Here, we imported the fmt package to formatting related functions.
In the main() function, we created a CountryCode map using make() function to store country code of specified country. Map store items in KEY/VALUE pair. Then we create a copy of the CountryCode map using the assignment operator and then print both maps on the console screen.
Program/Source Code:
The source code to create a copy of the map is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we declare the package main. The main package is used to tell the Go language compiler that the package must be compiled and produced the executable file. Here, we imported the fmt package to formatting related functions.
In the main() function, we created a CountryCode map using make() function to store country code of specified country. Map store items in KEY/VALUE pair. Then we create a copy of the CountryCode map using the assignment operator and then print both maps on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer