package
1.4.2
Repository: https://github.com/becklyn/go-wire-core.git
Documentation: pkg.go.dev

# README

Env

This package tries to locate a .env or .env.local file in your app directory (or the parent directory). .env.local is prefered over .env and variables that are already existing will not be overridden.

Usage

//go:build wireinject

package app

import (
	"github.com/fraym-work/go-wire-core/env"
	"github.com/google/wire"
)

func New() *env.Env {
	wire.Build(
		env.New,
	)
	return nil
}

Functions

env.GetEnvironment()

Will return the APP_ENV variables string value.

env.IsDevelopment()

Will return true if the APP_ENV variable is set to "dev". Useful to check if you are in development mode.

env.String("YOUR_ENV_VAR_NAME")

Returns the string value of your env variable.

env.StringWithDefault("YOUR_ENV_VAR_NAME", "your default")

Returns the string value of your env variable. If empty it will return the default string (in this case "your default").

env.Int("YOUR_ENV_VAR_NAME")

Returns the int value of your env variable.

env.IntWithDefault("YOUR_ENV_VAR_NAME", 123)

Returns the int value of your env variable. If empty it will return the default int (in this case 123).

env.Bool("YOUR_ENV_VAR_NAME")

Returns the bool value of your env variable (1 and "true" are equal to true).

env.BoolWithDefault("YOUR_ENV_VAR_NAME", true)

Returns the bool value of your env variable (1 and "true" are equal to true). If unset it will return the default bool (in this case true).