Create a map of string to List

前端 未结 3 1950
小蘑菇
小蘑菇 2020-12-08 04:10

I\'d like to create a map of string to container/list.List instances. Is this the correct way to go about it?

package main

import (
    \"fmt\"         


        
3条回答
  •  -上瘾入骨i
    2020-12-08 04:34

    My favorite syntax for declaring a map of string to slice of string:

    mapOfSlices := map[string][]string{
        "first": {},
        "second": []string{"one", "two", "three", "four", "five"},
        "third": []string{"quarter", "half"},
    }
    

提交回复
热议问题