func FromEnvOrDefault(key string, def string) string {
	var val string
	if v, ok := os.LookupEnv(key); ok {
		val = v
	} else {
		val = def
	}
	return val
}
Attempt to retrieve a value from an environment
variable if it is set. If not, use specified
default value
package mageutil
import (
	"fmt"
	"math/rand"
	"os"
)
func EnsureDir(dir string) {
	os.Mkdir(dir, os.ModePerm)
	os.Chmod(dir, os.ModePerm)
}
func RequireEnv(key string) string {
	val := os.Getenv(key)
	if val == "" {
		msg := fmt.Errorf("%s is a required environment variable\n", key)
		panic(msg)
	}
	return val
}