Go - Map remove element example

In this example, we show how to delete an element in a Map in Golang with an example.

An element is removed from a map with the delete function.

Go - Map remove element example

In the example, we remove one country from a map of countries:

package main

import "fmt"

func main() {

    countries := map[string]string{
        "IN": "India",
        "NP": "Nepal",
        "TR": "Turkey",
        "JP": "Japan",
        "ZW": "Zimbabwe",


    delete(countries, "NP")



map[IN:India JP:Japan NP:Nepal TR:Turkey ZW:Zimbabwe]
map[IN:India JP:Japan TR:Turkey ZW:Zimbabwe]

Free Spring Boot Tutorial - 5 Hours Full Course

Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course