agent/config/config.go
func (cfg *Config) Merge(rhs Config) *Config {
	left := reflect.ValueOf(cfg).Elem()
	right := reflect.ValueOf(&rhs).Elem()

	for i := 0; i < left.NumField(); i++ {
		leftField := left.Field(i)
		if utils.ZeroOrNil(leftField.Interface()) {
			leftField.Set(reflect.ValueOf(right.Field(i).Interface()))
		}
	}

	return cfg //make it chainable
}
func (cfg *Config) Merge(rhs Config) *Config {
	left := reflect.ValueOf(cfg).Elem()
	right := reflect.ValueOf(&rhs).Elem()

	for i := 0; i < left.NumField(); i++ {
		leftField := left.Field(i)
		if utils.ZeroOrNil(leftField.Interface()) {
			leftField.Set(reflect.ValueOf(right.Field(i).Interface()))
		}
	}

	return cfg //make it chainable
}
func ( cfg * Config ) Merge ( rhs Config ) * Config { left := reflect . ValueOf ( cfg ) . Elem ( ) right := reflect . ValueOf ( & rhs ) . Elem ( ) for i := 0 ; i < left . NumField ( ) ; i ++ { leftField := left . Field ( i ) if utils . ZeroOrNil ( leftField . Interface ( ) ) { leftField . Set ( reflect . ValueOf ( right . Field ( i ) . Interface ( ) ) ) } } return cfg //make it chainable }
// Merge merges two config files, preferring the ones on the left. Any nil or
// zero values present in the left that are not present in the right will be
// overridden
Merge merges two config files preferring the ones on the left . Any nil or zero values present in the left that are not present in the right will be overridden