I am trying to literally initialize the following struct in GO:
This is the struct:
type tokenRequest struct {
auth struct {
identity struct {
methods []string
password struct {
user struct {
name string
domain struct {
id string
}
password string
}
}
}
}
}
And this is my code:
req := &tokenRequest{
auth: struct {
identity: struct {
methods: []string{"password"},
password: {
user: {
name: os.Username,
domain: {
id: "default",
},
password: os.Password,
},
},
},
},
}
https://play.golang.org/p/e8Yuk-37_nN
Can I initialize without defining all the nested structs separately (i.e. auth
, identity
, password
, user
)
Thank you.