envy.go
func loadEnv() {
	gil.Lock()
	defer gil.Unlock()

	if os.Getenv("GO_ENV") == "" {
		// if the flag "test.v" is *defined*, we're running as a unit test. Note that we don't care
		// about v.Value (verbose test mode); we just want to know if the test environment has defined
		// it. It's also possible that the flags are not yet fully parsed (i.e. flag.Parsed() == false),
		// so we could not depend on v.Value anyway.
		//
		if v := flag.Lookup("test.v"); v != nil {
			env["GO_ENV"] = "test"
		}
	}

	// set the GOPATH if using >= 1.8 and the GOPATH isn't set
	if os.Getenv("GOPATH") == "" {
		out, err := exec.Command("go", "env", "GOPATH").Output()
		if err == nil {
			gp := strings.TrimSpace(string(out))
			os.Setenv("GOPATH", gp)
		}
	}

	for _, e := range os.Environ() {
		pair := strings.Split(e, "=")
		env[pair[0]] = os.Getenv(pair[0])
	}
}
func loadEnv() {
	gil.Lock()
	defer gil.Unlock()

	if os.Getenv("GO_ENV") == "" {
		// if the flag "test.v" is *defined*, we're running as a unit test. Note that we don't care
		// about v.Value (verbose test mode); we just want to know if the test environment has defined
		// it. It's also possible that the flags are not yet fully parsed (i.e. flag.Parsed() == false),
		// so we could not depend on v.Value anyway.
		//
		if v := flag.Lookup("test.v"); v != nil {
			env["GO_ENV"] = "test"
		}
	}

	// set the GOPATH if using >= 1.8 and the GOPATH isn't set
	if os.Getenv("GOPATH") == "" {
		out, err := exec.Command("go", "env", "GOPATH").Output()
		if err == nil {
			gp := strings.TrimSpace(string(out))
			os.Setenv("GOPATH", gp)
		}
	}

	for _, e := range os.Environ() {
		pair := strings.Split(e, "=")
		env[pair[0]] = os.Getenv(pair[0])
	}
}
func loadEnv ( ) { gil . Lock ( ) defer gil . Unlock ( ) if os . Getenv ( " " ) == " " { // if the flag "test.v" is *defined*, we're running as a unit test. Note that we don't care // about v.Value (verbose test mode); we just want to know if the test environment has defined // it. It's also possible that the flags are not yet fully parsed (i.e. flag.Parsed() == false), // so we could not depend on v.Value anyway. // if v := flag . Lookup ( " " ) ; v != nil { env [ " " ] = " " } } // set the GOPATH if using >= 1.8 and the GOPATH isn't set if os . Getenv ( " " ) == " " { out , err := exec . Command ( " " , " " , " " ) . Output ( ) if err == nil { gp := strings . TrimSpace ( string ( out ) ) os . Setenv ( " " , gp ) } } for _ , e := range os . Environ ( ) { pair := strings . Split ( e , " " ) env [ pair [ 0 ] ] = os . Getenv ( pair [ 0 ] ) } }
// Load the ENV variables to the env map
Load the ENV variables to the env map