doulangbi6869 2015-08-01 11:38
浏览 1128
已采纳

创建map [string] struct {}并分配一个值

I'm using the github.com/samalba/dockerclient and want to create a Container. So, the method is CreateContainer, which needs a ContainerConfig.

The ContainerConfig is a struct. And there's a field Volumes, wich type is type map[string] struct{}.

I know that I could create such a map with make(map[string]struct{})

But how do I assign values to the map?

  • 写回答

2条回答 默认 最新

  • 普通网友 2015-08-01 18:23
    关注
    cc := &dockerclient.ContainerConfig{
        // ...
        Volumes: map[string]struct{}{
            "foo": struct{}{},
            "bar": struct{}{},
            // ...
        },
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?