Skip to content
didslmPublic

About

Populate structs with environment values

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

env

A small library for populating structs with environment values.

No external dependencies, this is only dealing with environment and no files.

An example how to use it would be

type MyStruct struct {
	Field1 string `env:"FIELD_1"`
	Field2 int    `env:"FIELD_2"`
}

myStruct := MyStruct{}
env.PopulateWithEnv(&myStruct)

//you should see the data in your struct
fmt.Println(myStruct)

It supports also structs inside structs by taging it with obj:""

type MyStruct struct {
	Field1 string `env:"FIELD_1"`
	Field2 int    `env:"FIELD_2"`
}

type MainStruct struct {
	MyStruct `obj:"ref"`
}

struct := MainStruct{}
env.PopulateWithEnv(&struct)

//you should see the data in your struct
fmt.Println(struct)

About

Populate structs with environment values

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages