Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variables parsing in VariableGroup #186

Open
yacine-learning opened this issue Oct 24, 2024 · 0 comments
Open

Variables parsing in VariableGroup #186

yacine-learning opened this issue Oct 24, 2024 · 0 comments

Comments

@yacine-learning
Copy link

yacine-learning commented Oct 24, 2024

Currently this is how variables in VariableGroup are parsed

type VariableGroup struct {
        .....
	// Gets or sets variables contained in the variable group.
	Variables **map[string]interface{} `json:"variables,omitempty"`
}

In order to get the value of a specific variable, we need to some type assertion:

for key, variable := range *variableGroup.Variables {
		value := variable.(map[string]interface{})["value"]
		log.Printf("Variable Name: %v, Value: %v", key, value)
}

Could we not do this instead?

type VariableGroup struct {
        .....
	// Gets or sets variables contained in the variable group.
	Variables *map[string]map[string]interface{} `json:"variables,omitempty"`
}

Therefore we could get the value, this way:

for key, variable := range *variableGroup.Variables {
		vari := variable["value"]
		log.Printf("Variable Name: %v, Value: %v", key, vari)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant