func CollectFromEnvVars(to map[string]UnparsedVariableValue) {
	env := os.Environ()
	for _, raw := range env {
		if !strings.HasPrefix(raw, varEnvPrefix) {
			continue
		}
		raw = raw[len(varEnvPrefix):]  
		eq := strings.Index(raw, "=")
		if eq > 0 {
			name := raw[:eq]
			rawVal := raw[eq+1:]
			to[name] = unparsedVariableValueString{
				str:  rawVal,
				name: name,
			}
		}
	}
}
CollectFromEnvVars extracts the variable definitions from all environment variables that prefixed with TF_VAR_.
package tfvar
import (
	"io/ioutil"
	"os"
	"path/filepath"
	"strings"
	"github.com/cockroachdb/errors"
	"github.com/hashicorp/hcl/v2"
	"github.com/hashicorp/hcl/v2/hclsyntax"
	"github.com/hashicorp/hcl/v2/json"
	"github.com/hashicorp/terraform/configs"
	"github.com/zclconf/go-cty/cty"
)
const (
	defaultVarsFilename     = "terraform.tfvars"
	defaultVarsFilenameJSON = defaultVarsFilename + `.json`
)
func LookupTFVarsFiles(dir string) []string {
	var files []string
	d := filepath.Join(dir, defaultVarsFilename)
	if _, err := os.Stat(d); err == nil {
		files = append(files, d)
	}
	dj := filepath.Join(dir, defaultVarsFilenameJSON)
	if _, err := os.Stat(dj); err == nil {
		files = append(files, dj)
	}
	if infos, err := ioutil.ReadDir(dir); err == nil {
		for _, info := range infos {
			name := info.Name()
			if !isAutoVarFile(name) {
				continue
			}
			files = append(files, filepath.Join(dir, name))
		}
	}
	return files
}
func isAutoVarFile(path string) bool {
	return strings.HasSuffix(path, ".auto.tfvars") ||
		strings.HasSuffix(path, ".auto.tfvars.json")
}
type UnparsedVariableValue interface {
	ParseVariableValue(configs.VariableParsingMode) (cty.Value, error)
}