Default struct defaulter
requested to merge feature/default_struct_defaulter into feature/multi_region_support_multiple_platforms
Related tasks
Context
The defaults
package defines the Defaulter
interface to allow types to define custom logic to set default values. However, a majority of the structs do not require custom logic to set default values.
Change
This MR introduces a SetStructValues
function to the defaults
package. The new function is meant to allow structs to quickly implement the Defaulter
interface.
Example
import (
"gitlab.com/ignitionrobotics/web/cloudsim/pkg/defaults"
)
type Example struct {
Value string `default:"example"`
}
func (e *Example) SetDefaults() error {
return defaults.SetStructValues(e)
}
Other information
Additional documentation
Edited by Alejo Carballude