Haven
Haven

Reputation: 7966

create map of string slice in go

I am try to create a map of string slice with the code in GO

newMap := map [string][]string{
    "first" : {
        "good", "bad"
    },
    "second" : {
        "top", "bottom"
    }
}

It seems not to be the right way, what is the wrong with it?

Upvotes: 2

Views: 157

Answers (1)

nouney
nouney

Reputation: 4411

You have to add a comma , at the end of each initializer list.

newMap := map [string][]string{
    "first" : {
        "good", "bad",
    },
    "second" : {
        "top", "bottom",
    },
}

You can find a working example here.

Upvotes: 5

Related Questions