Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/segment-boneyard/go-env

Go wrapper around os.Getenv() that returns an error instead of empty string
https://github.com/segment-boneyard/go-env

Last synced: about 5 hours ago
JSON representation

Go wrapper around os.Getenv() that returns an error instead of empty string

Awesome Lists containing this project

README

        

# go-env

[![Build Status](https://travis-ci.org/segmentio/go-env.svg?branch=master)](https://travis-ci.org/segmentio/go-env)

Tiny wrapper around getenv() to return an error instead of an empty string when missing.

## Usage

#### func Get

```go
func Get(name string) (string, error)
```
Get env var `name` or return an error if it's missing.

#### func GetDefault

```go
func GetDefault(name string, value string) string
```
GetDefault returns `value` if environment variable `name` is not present.

#### func MustGet

```go
func MustGet(name string) string
```
MustGet panics if the environment variable is missing.

# License

MIT