Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type Config struct {
- path: string
- id: string
- key: string
- addr: string
- size: uint64
- }
- func merge(default *Config, file *Config) (*Config) {
- b := reflect.ValueOf(default)
- o := reflect.ValueOf(file)
- for i := 0; i < b.NumField(); i++ {
- defaultField := b.Field(i)
- fileField := o.Field(i)
- if defaultField.Interface() != reflect.Zero(fileField.Type()).Interface() {
- defaultField.Set(reflect.ValueOf(fileField))
- }
- }
- return default
- }
Add Comment
Please, Sign In to add comment