An overview of the

You can also create a shard of map data type in Golang. In fact, shards of any data type can be created in Go. Here is a simple example of creating a Map fragment

The program

package main

import "fmt"

func main(a) {
	maps := make([]map[string]string.3)

	map1 := make(map[string]string)
	map1["1"] = "a"

	map2 := make(map[string]string)
	map2["2"] = "b"

	map3 := make(map[string]string)
	map3["3"] = "c"

	maps[0] = map1
	maps[1] = map2
	maps[2] = map3

	for _, m := range maps {
		fmt.Println(m)
	}
}
Copy the code

The output

map[1:a]
map[2:b]
map[3:c]
Copy the code

In the above program, we created three maps of type map[string]string.

map1 := make(map[string]string)
map1["1"] = "a"

map2 := make(map[string]string)
map2["2"] = "b"

map3 := make(map[string]string)
map3["3"] = "c"
Copy the code

We also create a shard of the map data type, like this

maps := make([]map[string]string.3)
Copy the code

This is how we create a fragment of a map

Take a look at our advanced Golang tutorial. This series of tutorials is carefully designed and we try to cover all the concepts with examples. This tutorial is for those who wish to gain professional knowledge and a solid understanding of Golang -Golang Advanced Tutorial

If you are interested in learning how to implement all design patterns in Golang. If so, then this article is for you — All Design Patterns Golang

The postSlice of Map in Go (Golang)appeared first onWelcome To Golang By Example.