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


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.

I'm working on some more Cheat Sheets book on Jquery, TypeScript, React js and for other languages. I will send it once it's completed.

Related Posts