code: func (ms ModuleSources) UnusedFilename(proposed string) string {
  	ext := fileExt(proposed)
  	if ext == "" {
  		panic(fmt.Errorf("method UnusedFilename used with invalid proposal %q", proposed))
  	}
  
  	if _, exists := ms[proposed]; !exists {
  		return proposed
  	}
  
  	base := proposed[:len(proposed)-len(ext)]
  	for i := 1; ; i++ {
  		try := fmt.Sprintf("%s-%d%s", base, i, ext)
  		if _, exists := ms[try]; !exists {
  			return try
  		}
  	}
  }
docs: // UnusedFilename finds a filename that isn't already used by a file in
  // the receiving sources and returns it.
  //
  // The given "proposed" name is returned verbatim if it isn't already used.
  // Otherwise, the function will try appending incrementing integers to the
  // proposed name until an unused name is found. Callers should propose names
  // that they do not expect to already be in use so that numeric suffixes are
  // only used in rare cases.
  //
  // The proposed name must end in either ".tf" or ".tf.json" because a
  // ModuleSources only has visibility into such files. This function will
  // panic if given a file whose name does not end with one of these
  // extensions.
  //
  // A ModuleSources only works on one directory at a time, so the proposed
  // name must not contain any directory separator characters.