venv

package module
v0.0.0-...-e777897 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: MIT Imports: 2 Imported by: 12

README

venv

GoDoc Build Status

This is a Go library to abstract access to environment variables.
Like spf13/afero or blang/vfs, but for the env.

Usage

package main

import (
	"fmt"
	"github.com/adammck/venv"
)

func main() {
	var e venv.Env

	// Use the real environment

	e = venv.OS()
	fmt.Printf("Hello, %s!\n", e.Getenv("USER"))

	// Or use a mock

	e = venv.Mock()
	e.Setenv("USER", "fred")
	fmt.Printf("Hello, %s!\n", e.Getenv("USER"))
}

License

MIT.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Env

type Env interface {
	Environ() []string
	Getenv(key string) string
	LookupEnv(key string) (string, bool)
	Setenv(key, value string) error
	Clearenv()
}

func Mock

func Mock() Env

func OS

func OS() Env

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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