如何在Golang中为嵌套数组结构初始化变量?

I am parsing a JSON file in Golang, by making a nested struct, and able to do it successfully. However, now I wish to make a variable of the same struct, but I get the following error cannot use []Specs literal (type []Specs) as type []Specs in field value. Could someone please point out my mistake here? What am I doing wrong?

This is the Nested Struct:

type Config struct {
OrdererOrgs []OrdererOrgs `json:"OrdererOrgs"`
PeerOrgs []PeerOrgs `json:"PeerOrgs"`
}

type OrdererOrgs struct {
Name string `json:"name"`
Domain string `json:"Domain"`
Specs []Specs `json:"Specs"`
}

type Specs struct {
Hostname string `json:"Hostname"`
Commonname string `json:"Commonname"`
}

type PeerOrgs struct {
Name   string `json:"name"`
Domain   string `json:"Domain"`
Template Template `json:"Template"`
Users Users `json:"Users"`
}

type Template struct {
Count int `json:"Count"`
Start int `json:"Start"`
}

type Users struct {
Count int `json:"Count"`
}

And this is my variable:

newconfig:= Config{
    OrdererOrgs: []OrdererOrgs{
        OrdererOrgs{
            Name: "Orderer1",
            Domain : "Domain",
            Specs: []Specs{
                Specs{
                Hostname: "H",
                Commonname: "C",
                },
                Specs{
                    Hostname: "H",
                    Commonname: "C",
                    },
            },
        },
        OrdererOrgs{
            Name: "Orderer2",
            Domain : "Domain2",
            Specs: []Specs{
                Specs{
                Hostname: "H",
                Commonname: "C",
                },
            },
        },
    },
    PeerOrgs: []PeerOrgs{
        PeerOrgs{
            Name: "Org1",
            Domain: "D",
            Template: Template{
                Count: 1,
                Start: 0,
            },
            Users: Users{
                Count: 1,
            },
        },
        PeerOrgs{
            Name: "Org2",
            Domain: "D2",
            Template: Template{
                Count: 1,
                Start: 0,
            },
            Users: Users{
                Count: 1,
            },
        },
    },
}

Welcome to StackOverflow! As Volker said in a comment, your code seems to be working. Are you sure you're seeing the issue now? Can you run the playground link Volker provided?

In general, this is possible in Go via the composite literals feature; that link has several useful examples along with a discussion of semantics that you may find interesting. If something stops working I'd recommend building progressively more complicate structures until you see where the problem is, until you reach the level of nesting needed for your application.