getenv

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 5 Imported by: 2

README

GetEnv

Go Reference Bitbucket Pipelines

Installation

go get bitbucket.org/amotus/getenv

Usage

package main

import (
	"time"

	"bitbucket.org/amotus/getenv"
)

func main() {
	s := getenv.String("VAR_STRING", "default")
	i := getenv.Int("VAR_INT", 0)
	i64 := getenv.Int64("VAR_INT64", int64(0))
	b := getenv.Bool("VAR_BOOL", false)
	t := getenv.TimeDuration("VAR_TIME", 60*time.Second)
}

License

Licensed under Apache License, Version 2.0 LICENSE.

Documentation

Overview

Package getenv provide the implementation of a LookupEnv pattern with default value handling

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(key string, defaultValue bool) bool

Bool returns the bool value of the environment variable named by the key, or defaultValue if the environment variable is not set. It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. Any other value returns default value.

func Int

func Int(key string, defaultValue int) int

Int returns the int value of the environment variable named by the key, or defaultValue if the environment variable is not set.

func Int64

func Int64(key string, defaultValue int64) int64

Int64 returns the int64 value of the environment variable named by the key, or defaultValue if the environment variable is not set.

func IntArray added in v0.0.2

func IntArray(key string, defaultValue []int) []int

IntArray returns an array of integers from the environment variable by the key, or the default value if the environment variable is not set. It accepts any array of int value as long as the array is in a string "[56, 8, 1]" Any other value returns default value.

func String

func String(key string, defaultValue string) string

String returns the string value of the environment variable named by the key, or defaultValue if the environment variable is not set.

func TimeDuration

func TimeDuration(key string, defaultValue time.Duration) time.Duration

TimeDuration returns the time.Duration value of the environment variable named by the key, or defaultValue if the environment variable is not set.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳