How to initialize an empty map in Golang?
May 24, 2022Hi Friends 👋,
Welcome To aGuideHub! ❤️
Today, I’m going to show you how I do initialize an empty map in Golang, to create an empty map I follow a basic style just I will not put any data in it.
Let’s start today’s tutorial How to initialize an empty map in Golang?
Here I will create a sample variable and store an empty map, then I will use the print method to check if it’s empty or not.
Okey, let’s start the code.
package main
import "fmt"
func main() {
x := map[string]string{}
fmt.Println(x)
}
when you run above program it will print map[]
like in golang console.
let’s check the output.
All the best 👍