package
1.10.1
Repository: https://github.com/kodekoding/phastos.git
Documentation: pkg.go.dev

# README

godoc

Env

This small package give some functionality to common usage of detecting Tokopedia runtime ecosystem using TKPENV environment variable.

Other usecase is to set the environment variables using file, this is handy if you want to run your app in your laptop with custom value depending on your local ecosystem. For example your app will readDB_CONN to fetch connection string to database, you can create file containing envar to set before application initialize connection to database.

At default env will look for file .env in current directory and load the value. If you want to load env file from other place then you can use SetFromEnvFile(<path>).

Example

.env

DB_CONN=postgres://foo@bar/database

main.go

import _ "github.com/kodekoding/phastos/go/env" // this will enough just to trigger env to look for .env file

func main(){
    initializeDbConnection() // your function that read DB_CONN 
}

# Functions

GoVersion to return current build go version.
IsDevelopment return true when env is "development".
IsLocal return true when env is "local".
IsProduction return true when env is "production".
IsStaging return true when env is "staging".
ServiceEnv return ServiceENV service environment.
SetFromEnvFile read env file and set the environment variables.

# Constants

Env list.
Env list.
Env list.
Env list.

# Variables

Env related var.

# Type aliases

ServiceNameEnv type, not used anymore.