Golang map string string example
May 14, 2022Hi Friends 👋,
Welcome To aGuideHub! ❤️
Today, we are going to create a map with their key and value both are in string type, here we will use the static typing concept to create a map.
First, we will define the map type key as a string and value as a string, so we have to write like below.
m := make(map[string]string)
After defining the map type we have to store some sample key values, let’s check how we can do it.
package main
import "fmt"
func main() {
// here we are define map type
m := make(map[string]string)
m["k1"] = "First"
m["k2"] = "Second"
fmt.Println("map:", m)
}
When you run it, you will get map key values in your golang console, let’s check the output.
All the best 👍