GO language program with an example of Hash Table
Maps are un-ordered collections, and there's no way to predict the order in which the key/value pairs will be returned. Every time when you run the program, every iteration over a map could return a different order.
Example
// GO language program with an example of Hash Table
package main
import (
"fmt"
)
func main() {
var country map[int]string
country = make(map[int] string)
country[1]="India"
country[2]="China"
country[3]="Pakistan"
country[4]="Germany"
country[5]="Australia"
country[6]="Indonesia"
for i, j := range country {
fmt.Printf("Key: %d Value: %s\n", i, j)
}
}
Most Helpful This Week
How to Improve the Performance of Your Golang Application?
Golang program for implementation of Longest Common Sub-sequence
Example to compare Println vs Printf
How to add items to Slice using append function in Golang?
How do you create an HTTP server in Go?
Go program to reading plain text files
Golang writing struct to JSON file
How to check specific field exist in struct?
GO supports the standard arithmetic operators: (Addition, Subtraction, Multiplication, Division,Remainder)
Go program to find Name Server (NS) record of a domain