简体   繁体   中英

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM