Golang map string string example

Hi 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.

map string string, golang

Try it yourself

All the best 👍

Premium Content

You can get all the below premium content directly in your mail when you subscribe us

Books

Interview Questions

Soon You will get CSS, JavaScript, React Js, and TypeScript So Subscribe to it.

Portfolio Template

View | Get Source Code

Cheat Sheets

Cheat Sheets Books are basically Important useful notes which we use in our day-to-day life.

Related Posts