env

package
v0.10.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

README

Env

The env package is used to load environment variables in the context of using the core-mage targets and development environment. It provides convenient functions for loading or overloading.

Example

Loading default environment
func main() {
    env.LoadDefault()
}
Loading specific environment files
func main() {
    env.Load("infa/does-not-override.env")
    env.Overload("infa/will-override.env")
}
Loading default test configuration
func TestMain(m *testing.M) {
	env.MustLoadDefaultTest(m)
	os.Exit(m.Run())
}
Loading specific files during the testing
func TestMain(m *testing.M) {
    env.LoadTest(m, "infa/does-not-override.env")
    env.OverloadTest(m, "infa/will-override.env")
    os.Exit(m.Run())
}

Documentation

Overview

Package env is used to load environment variables in the context of using the core-mage targets and development environment. It provides convenient functions for loading or overloading.

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// DevFiles represents the development files to be loaded in order.
	DevFiles = []string{
		"infra/personal.env",
		"infra/local.dev.env",
		"infra/common.env",
		".env",
	}

	// TestFiles represents the test files to be loaded in order.
	TestFiles = []string{
		"infra/local.test.env",
		"infra/common.env",
	}
)
View Source
var (
	// DefaultMigrationsPath is the default path to migrations relative from the project root.
	DefaultMigrationsPath = "service/database/migrations"
)

Functions

func Load added in v0.9.0

func Load(paths ...string)

Load tries to load given env files, leaving current environment variables intact.

Example
package main

import (
	"github.com/LUSHDigital/core-mage/env"
)

func main() {
	env.Load("infa/does-not-override.env")
}
Output:

func LoadDefault added in v0.9.0

func LoadDefault()

LoadDefault will attempt to load the default environment.

func LoadTest added in v0.9.0

func LoadTest(m *testing.M, paths ...string)

LoadTest tries to load given env files, leaving current environment variables intact.

Example
package main

import (
	"testing"

	"github.com/LUSHDigital/core-mage/env"
)

var m *testing.M

func main() {
	env.LoadTest(m, "infa/does-not-override.env")
}
Output:

func MigrationsTestURL added in v0.9.4

func MigrationsTestURL(m *testing.M) string

MigrationsTestURL returns the migrations path relative to the project root.

func MustLoadDefaultTest added in v0.9.0

func MustLoadDefaultTest(m *testing.M)

MustLoadDefaultTest will attempt to load the default test environment.

func Overload added in v0.9.0

func Overload(paths ...string)

Overload tries to overload given env files, overriding current environment variables.

Example
package main

import (
	"github.com/LUSHDigital/core-mage/env"
)

func main() {
	env.Overload("infa/will-override.env")
}
Output:

func OverloadTest added in v0.9.0

func OverloadTest(m *testing.M, paths ...string)

OverloadTest tries to overload given env files, overriding current environment variables.

Example
package main

import (
	"testing"

	"github.com/LUSHDigital/core-mage/env"
)

var m *testing.M

func main() {
	env.OverloadTest(m, "infa/will-override.env")
}
Output:

Types

This section is empty.

Directories

Path Synopsis
internal
mod

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL