Skip to content

papasavva/formicidae

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

formicidae

Update .env files in Go with code.

GitHub Workflow Status Go Report Card

What is fomicidae?

formicidate is a small tool for Go application. You can update the value of environment variables in a .env file with code. This can be handy in situations that you want to update the values programmatically like in unit tests.

Installation

go get github.com/papasavva/formicidae

Usage

Add your application configuration to your .env file of your project:

S3_BUCKET=myBucket
SECRET_KEY=mySecretKeyGoesHere

Then in your app you can do something like:

package main

import (
    "github.com/papasavva/formicidae"
)

func main() {
	updatedContent, err := formicidae.UpdateVariable(".env", "SECRET_KEY", "myNewSecretKey")
	...
}

Notes

  • If you wish to update multiple variables, you can call the function multiple times.
  • The function will return the content of the whole file.

Contributing

Contributions are welcomed.

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Licence

The code is licensed under the permissive MIT licence. Read this for a summary.

About

Update .env files in Go

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages