Hi Experts,
Am new to Golang and stuck with calling array element in Golang, on internet i don't find any example of array element with user inputs.
Here is the snippet of function which is getting failed during compile.
func resourceRoleManagementCreate(d *schema.ResourceData, meta interface{}) error {
config := meta.(Config)
resourceAction := "create"
rc := &RoleCreate{
Action: resourceAction,
Resources: RoleCreateConfig{
Name: d.Get("name").(string),
Settings: SettingsConfig{
Restrictions: Restrictions{
Vms: d.Get("vms").(string),
},
},
Features: FeaturesConfig{
Identifier: d.Get("identifier").(string),
},
},
}
Schema definition is as below:
// RoleConfig for Role Management
type RoleCreate struct {
Action string `json:"action"`
Resources RoleCreateConfig `json:"resources"`
}
type FeaturesConfig struct {
Identifier string `json:"identifier"`
}
type RoleCreateConfig struct {
Name string `json:"name"`
Settings SettingsConfig `json:"settings"`
Features []FeaturesConfig `json:"features"`
}
type SettingsConfig struct {
Restrictions Restrictions `json:"restrictions"`
}
type Restrictions struct {
Vms string `json:"vms"`
}
Error am getting while compiling is as below:
infra8/resource_role_management.go:58:14: cannot use FeaturesConfig{…} (value of type FeaturesConfig) as type []FeaturesConfig in struct literal
make: *** [build] Error 2
Top comments (0)