envconv

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrFromFile

func ArrFromFile(name string) ([]string, error)

ArrFromFile takes a path to a file with the content of a .env file e.g.

	FOO=bar
 KEY=val

and returns a corresponding environment array

["FOO=bar", "KEY=val"].

func ArrFromReader

func ArrFromReader(r io.Reader) ([]string, error)

ArrFromReader takes a Reader with the content of a .env file e.g.

	FOO=bar
 KEY=val

and returns a corresponding environment array

["FOO=bar", "KEY=val"].

func ArrToMap

func ArrToMap(a []string) map[string]string

ArrToMap takes an environment array of the form

["KEY1=val1", "KEY2=val2"]

and returns a corresponding map of the form

{
	"KEY1": "val1",
	"KEY2": "val2"
}

func MapFromFile

func MapFromFile(name string) (map[string]string, error)

MapFromFile takes a path to a file with the content of a .env file e.g.

	FOO=bar
 KEY=val

and returns a corresponding map

{
	"FOO": "bar",
	"KEY": "val"
}

func MapFromReader

func MapFromReader(r io.Reader) (map[string]string, error)

MapFromReader takes a Reader with the content of a .env file e.g.

	FOO=bar
 KEY=val

and returns a corresponding map

{
	"FOO": "bar",
	"KEY": "val"
}

func MapToArr

func MapToArr(m map[string]string) []string

MapToArr takes an map of the form

{
	"KEY1": "val1",
	"KEY2": "val2"
}

and returns a corresponding array of the form

["KEY1=val1", "KEY2=val2"].

func PathFromFile

func PathFromFile(name string) (string, error)

PathFromReader takes a path to a file with newline-delimited directory paths e.g.

/usr/local/bin
/usr/bin

and returns a corresponding PATH environment variable

/usr/local/bin:/usr/bin.

func PathFromReader

func PathFromReader(r io.Reader) (string, error)

PathFromReader takes a Reader with newline-delimited directory paths e.g.

/usr/local/bin
/usr/bin

and returns a corresponding PATH environment variable

/usr/local/bin:/usr/bin.

func ToMap

func ToMap(ss ...string) map[string]string

ToMap is a convenience function wrapping ArrToMap. It takes an environment array of the form

["KEY1=val1", "KEY2=val2"]

and returns a corresponding map of the form

{
	"KEY1": "val1",
	"KEY2": "val2"
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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