Skip to content

Latest commit

 

History

History
31 lines (25 loc) · 746 Bytes

README.md

File metadata and controls

31 lines (25 loc) · 746 Bytes

golang-envStore

Store your environment variables from multiple sources (files, strings, JSON and the operating system) in one data structure, allowing easy access (potentially concurrent) from within your program.

Example

package main

import (
	envStore "github.com/theTardigrade/golang-envStore"
)

func main() {
	env, err := envStore.New(&envStore.Config{
		FromFilePaths: []string{"data1.env", "data2.env"},
		FromStrings: []string{"x=128\ny=test\nz=/bin/bash"},
		FromJSONSlices: [][]byte{[]byte(`{"key":"value","key2":"value2"}`)},
		FromSystem: true,
		UseMutex: true,
		IgnoreEmptyLines: true,
	})
	if err != nil {
		panic(err)
	}

	env.Iterate(func(key, value string) {
		fmt.Printf("%v :: %v\n", key, value)
	})
}