func (c *Conf) Set(name string, initial Env, overrides ...Env) (*Env, error) {
	if name == "" {
		return nil, ErrInvalidEnvironmentName
	}
	var err error
	c.Envs[name], err = newEnv(name, initial, append([]Env{c.osEnv}, overrides...)...)
	return c.Envs[name], err
}
Set will set the environment value and then mixin any overrides passed in. The os
overrides and defaults will also be mixed into the new environment
package env
import (
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"os"
	"path/filepath"
	"encoding/json"
	"github.com/caarlos0/env"
	"github.com/joho/godotenv"
	"github.com/shibukawa/configdir"
	"gopkg.in/yaml.v1"
)
const (
	vendor   = "Shopify"
	appname  = "Themekit"
	filename = "variables"
)
var (
	cdir          = configdir.New(vendor, appname)
	supportedExts = []string{"yml", "yaml", "json"}
	ErrEnvDoesNotExist = errors.New("environment does not exist in this environments list")
	ErrEnvNotDefined = errors.New("environment was found but not defined")
	ErrNoEnvironmentsDefined = errors.New("no environments defined, nothing to write")
	ErrInvalidEnvironmentName = errors.New("environment name cannot be blank")
)
type Conf struct {
	Envs  map[string]*Env
	osEnv Env
	path  string
}
func init() {
	cdir.LocalPath, _ = os.Getwd()
}
func SourceVariables(flagpath string) error {
	if flagpath != "" {
		return godotenv.Load(flagpath)
	}
	if fldr := cdir.QueryFolderContainsFile(filename); fldr != nil {
		return godotenv.Load(filepath.Join(fldr.Path, filename))
	}
	return nil
}
func New(configPath string) Conf {
	conf := Conf{
		Envs:  make(map[string]*Env),
		osEnv: Env{},
		path:  configPath,
	}
	env.Parse(&conf.osEnv)
	return conf
}
func Load(configPath string) (Conf, error) {
	conf := New(configPath)
	path, ext, err := searchConfigPath(configPath)
	if err != nil {
		return conf, err
	}
	contents, err := ioutil.ReadFile(path)
	if err != nil {
		return conf, err
	}
	contents = []byte(os.ExpandEnv(string(contents)))
	switch ext {
	case "yml", "yaml":
		if err = yaml.Unmarshal(contents, &conf.Envs); err != nil {
			return conf, fmt.Errorf("Invalid yaml found while loading the config file: %v", err)
		}
	case "json":
		if err = json.Unmarshal(contents, &conf.Envs); err != nil {
			return conf, fmt.Errorf("Invalid json found while loading the config file: %v", err)
		}
	}
	return conf, nil
}