golang在嵌套结构中初始化内部结构对象

I have a nested struct

type Posts struct {
    Id        int
    CreatedAt time.Time
    Data      struct {
        Title    string
        UserName string
    }
}

I want to create a Data object but var innerData Posts.Data doesn't seem to work. I don't want to create separate Data struct because I'm planning to avoid name collusions by having multiple structs which will have different inner structs named Data.

You can't. Posts.Data isn't the name of a type. The only thing you could do is var innerData struct{ ... }, which I'm sure you don't want to because then you would have repetition and need to make changes in two places. Otherwise, you have to give it a name. That name doesn't have to be Data, it can be PostData or something to make it unique.