Skip to content

A Go package to locate and load .env files from any directory efficiently

License

Notifications You must be signed in to change notification settings

ignat-one/dotenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dotenv Loader

A simple Go package to locate and load .env files from any directory efficiently.

Installation

go get github.com/ignat-one/dotenv

Usage

package main

import (
    "log"
    "github.com/ignat-one/dotenv"
)

func main() {
    err := dotenv.Load()
    if err != nil {
        log.Fatal(err)
    }
    // environment variables are now loaded
}

Usage with options

package main

import (
    "log"
    "github.com/ignat-one/dotenv"
)

func main() {
    err := dotenv.Load(
        dotenv.WithAnchorFile("your-anchor.file"),
        dotenv.WithFilename("your.env"),
    )
    if err != nil {
        log.Fatal(err)
    }
    // environment variables are now loaded
}

Options

  • WithAnchorFile(filename string): Specify a custom anchor file to help locate the .env file. The default value is "go.mod"

  • WithFilename(filename string): Specify a custom environment filename. The default value is ".env"

Contributing

Feel free to submit issues and enhancement requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A Go package to locate and load .env files from any directory efficiently

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages