func fieldOptsOverride()

in merge.go [532:560]


func fieldOptsOverride(opts *options, fieldName string, idx int) (*options, Error) {
	if opts.fieldHandlingTree == nil {
		return opts, nil
	}
	cfgHandling, child, ok := opts.fieldHandlingTree.fieldHandling(fieldName, idx)
	child, err := includeWildcard(child, opts.fieldHandlingTree)
	if err != nil {
		return nil, err
	}
	if !ok {
		// Only return a new `options` when arriving at new nested child. This
		// combined with optimizations in `includeWildcard` will ensure that only
		// a new opts will be created and returned when absolutely required.
		if child != nil && opts.fieldHandlingTree != child {
			newOpts := *opts
			newOpts.fieldHandlingTree = child
			opts = &newOpts
		}
		return opts, nil
	}
	// Only return a new `options` if absolutely required.
	if opts.configValueHandling != cfgHandling || opts.fieldHandlingTree != child {
		newOpts := *opts
		newOpts.configValueHandling = cfgHandling
		newOpts.fieldHandlingTree = child
		opts = &newOpts
	}
	return opts, nil
}