env

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-env

Simple go lib for environment variables with default values.

Use

Functions:

  • GetBool()
  • GetString()
  • GetInt()
  • GetInt64()
  • GetFloat32()
  • GetFloat64()
  • GetUint()
  • GetUint64()
  • GetDuration()
Instalation
    go get github.com/amonsat/go-env
Basic Use
package main

import env "github.com/amonsat/go-env"

var (
    debug := env.GetBool("DEBUG", false)
    mongoAddr := env.GetString("MONGO_ADDR", "mongodb://127.0.0.1:27017")
)

func main() {
    println("Debug mode: ", debug)
    println("Mongo addr: ", mongoAddr)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBool

func GetBool(key string, def bool) bool

GetBool - get bool environment variable or default value

func GetDuration added in v1.1.0

func GetDuration(key string, def time.Duration) time.Duration

GetDuration - get time.Duration environment variable or default value

func GetFloat32

func GetFloat32(key string, def float32) float32

GetFloat32 - get float environment variable or default value

func GetFloat64

func GetFloat64(key string, def float64) float64

GetFloat64 - get float64 environment variable or default value

func GetInt

func GetInt(key string, def int) int

GetInt - get int environment variable or default value

func GetInt64

func GetInt64(key string, def int64) int64

GetInt64 - get int64 environment variable or default value

func GetString

func GetString(key, def string) string

GetString - get string environment variable or default value

func GetUint

func GetUint(key string, def uint) uint

GetUint - get uint environment variable or default value

func GetUint64

func GetUint64(key string, def uint64) uint64

GetUint64 - get uint64 environment variable or default value

Types

This section is empty.

Jump to

Keyboard shortcuts

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