code: func (p *Parser) LoadConfigDir(path string) (*Module, hcl.Diagnostics) {
  	primaryPaths, overridePaths, diags := p.dirFiles(path)
  	if diags.HasErrors() {
  		return nil, diags
  	}
  
  	primary, fDiags := p.loadFiles(primaryPaths, false)
  	diags = append(diags, fDiags...)
  	override, fDiags := p.loadFiles(overridePaths, true)
  	diags = append(diags, fDiags...)
  
  	mod, modDiags := NewModule(primary, override)
  	diags = append(diags, modDiags...)
  
  	mod.SourceDir = path
  
  	return mod, diags
  }
docs: // LoadConfigDir reads the .tf and .tf.json files in the given directory
  // as config files (using LoadConfigFile) and then combines these files into
  // a single Module.
  //
  // If this method returns nil, that indicates that the given directory does not
  // exist at all or could not be opened for some reason. Callers may wish to
  // detect this case and ignore the returned diagnostics so that they can
  // produce a more context-aware error message in that case.
  //
  // If this method returns a non-nil module while error diagnostics are returned
  // then the module may be incomplete but can be used carefully for static
  // analysis.
  //
  // This file does not consider a directory with no files to be an error, and
  // will simply return an empty module in that case. Callers should first call
  // Parser.IsConfigDir if they wish to recognize that situation.
  //
  // .tf files are parsed using the HCL native syntax while .tf.json files are
  // parsed using the HCL JSON syntax.