gocanto / go-environment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

About

tests workflow Go Report Card Go Reference

Slim library to read environment files (.env) variables.

Installation

This library is based on GO. So before using it, make sure you have it installed in your machine.

Once you have done this, you will be able to pull this library in by typing the following command in your terminal within your go application or library.

First, you need to ope you terminal and cd into your project directory, like so:

cd $HOME/your-project-rote-folder

After doing so, you would be able to type the following command to get this library installed. For instance,

go get github.com/voyago/environment

Note: Make sure you have properly configured you go project.

How do I use this library?

    PackageDir := "YOUR_PROJECT_BASE_DIR_NAME"
    env, err := Make(PackageDir)

	if err != nil {
		t.Errorf("%v", err)
		t.FailNow()
	}

	if env.GetRootDir() != PackageDir {
		t.Errorf("The given env root directory is invalid")
	}

	if env.Get("ANY_KEY_CONTAINED_IN_YOUR_ENV_FILE") != "foo" {
		t.Errorf("The given env key is invalid")
	}

For more examples, please visit the tests file.

Contributing

Please, feel free to fork this repository to contribute to it by submitting a functionalities/bugs-fixes pull request to enhance it.

License

Please see License File for more information.

How can I thank you?

There are many ways you would be able to support my open source work. There is not a right one to choose, so the choice is yours.

Nevertheless 😀, I would propose the following

  • ⬆️ Follow me on Twitter.
  • ⭐ Star the repository.
  • 🤝 Open a pull request to fix/improve the codebase.
  • ✍️ Open a pull request to improve the documentation.
  • ☕ Buy me a coffee?

Thank you for reading this far. 😊

About

License:MIT License


Languages

Language:Go 96.6%Language:Makefile 1.7%Language:Shell 1.7%