code: func NewDecoder(config *DecoderConfig) (*Decoder, error) {
  	val := reflect.ValueOf(config.Result)
  	if val.Kind() != reflect.Ptr {
  		return nil, errors.New("result must be a pointer")
  	}
  
  	val = val.Elem()
  	if !val.CanAddr() {
  		return nil, errors.New("result must be addressable (a pointer)")
  	}
  
  	if config.Metadata != nil {
  		if config.Metadata.Keys == nil {
  			config.Metadata.Keys = make([]string, 0)
  		}
  
  		if config.Metadata.Unused == nil {
  			config.Metadata.Unused = make([]string, 0)
  		}
  	}
  
  	if config.TagName == "" {
  		config.TagName = "mapstructure"
  	}
  
  	result := &Decoder{
  		config: config,
  	}
  
  	return result, nil
  }
docs: // NewDecoder returns a new decoder for the given configuration. Once
  // a decoder has been returned, the same configuration must not be used
  // again.