Http 带计算键的Go结构

Http 带计算键的Go结构,http,post,go,struct,types,Http,Post,Go,Struct,Types,如何在Go中为以下数据结构创建struct { "description": String, "public": Boolean, "files": { "some_filename.txt": { "contents": String } } } 我从以下几点开始: type File struct { // stuck here? } type Payload struct {

如何在Go中为以下数据结构创建
struct

{
    "description": String,
    "public":      Boolean,
    "files": {
        "some_filename.txt": {
            "contents": String
        }
    }
}
我从以下几点开始:

type File struct {
    // stuck here?
}

type Payload struct {
    Description string
    Public      bool
    Files       File
}

如果您能在HTTP post请求中使用此项,我们将不胜感激。

在编译时不知道密钥时,请使用映射:

type File struct {
    Contents string
}

type Payload struct {
    Description string
    Public      bool
    Files       map[string]*File
}

Go不是动态键入的。重新设计。对于需要这样做的实际情况:查看包反映。我感谢您的反馈,谢谢。