Answers for "golang initialize nested struct"

Go
0

golang initialize nested struct

type Configuration struct {
    Val string
    Proxy Proxy
}

type Proxy struct {
    Address string
    Port    string
}

func main() {

    c := &Configuration{
        Val: "test",
        Proxy: Proxy{
            Address: "addr",
            Port:    "port",
        },
    }
    fmt.Println(c)
    fmt.Println(c.Proxy.Address)
}
Posted by: Guest on March-08-2020

Code answers related to "golang initialize nested struct"

Browse Popular Code Answers by Language