Skip to content

sboehmann/envconf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

envconf

A Go (Golang) library for managing configuration data from environment variables which is used by my Twelve-Factor Apps.

GoDoc Travis CI Status Coverage Status Go Report Card

Installation

Download and install it:

go get -u github.com/sboehmann/envconf

Import it in your code:

import "github.com/sboehmann/envconf"

Quick start

First you need a few environment variables:

export MY_PORT=8080
export MY_MESSAGE="Hello World!"

And now a simple program that uses these variables:

package main

import (
    "github.com/sboehmann/envconf"
    "io"
    "net/http"
)

func message(w http.ResponseWriter, r *http.Request) {
    value, _ := envconf.GetString("MESSAGE")
    io.WriteString(w, value)
}

func main() {
    envconf.SetPrefix("MY_")

    http.HandleFunc("/", message)
    http.ListenAndServe(":"+envconf.MustGetString("PORT"), nil)
}

About

A Go (golang) library for managing configuration data from environment variables which is used by my Twelve-Factor Apps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages