env

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2022 License: AGPL-3.0 Imports: 1 Imported by: 0

README

Env

GoDoc Go Report Card Maintainability Tests Test Coverage

This is a minimalistic library for accessing environment variables in Go.

Features

  • Simple methods for creating and retrieving environment variables
  • Allows a fallback value if an environment variable is not set

Usage

package main

import (
    "github.com/rrandall91/env"
)

func main() {
    // Create a new environment variable
    env.Set("MY_ENV_VAR", "my value")

    // Get the value of an environment variable or a fallback value if it is not set
    env.Get("MY_ENV_VAR", "fallback value")

    // Get the value of an environment variable with a fallback
    env.GetWithDefault("MY_ENV_VAR", "default value")
}

License

Copyright (c) 2022-present Rashaad Randall. Env is free and open-source software licensed under the GNU Affero General Public License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(key string) string

Get returns the value of the environment variable named by the key or the fallback value if the variable is not set.

func GetWithDefault

func GetWithDefault(key string, fallback string) string

GetWithDefault returns the value of the environment variable named by the key or the default value if the variable is not set.

func Set

func Set(key string, value string)

Set sets the value of the environment variable named by the key.

Types

This section is empty.

Jump to

Keyboard shortcuts

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