gotenv

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 3 Imported by: 0

README

Gotenv?

Gotenv is a very simple Go package to load environment variables from a .env format file. Documentation for the package can be found here.

The library has two main features:

  1. Load from a default .env file.
  2. Load from a specified file in the .env format.

To install, simply do the following:

go get github.com/STBoyden/gotenv@latest

Documentation

Overview

gotenv is a general-purpose package to load environment variables from files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadEnv

func LoadEnv(overrideExistingVars bool) (map[string]string, error)

LoadEnv assumes default values for LoadEnvFromFile, where the filePath is equal to ".env" and the returnNilErrOnNoFile is true. See LoadEnvFromFile for specific documentation on parameters.

func LoadEnvFromFile

func LoadEnvFromFile(filePath string, returnNilErrOnNoFile, overrideExistingVars bool) (map[string]string, error)

LoadEnvFromFile reads a given "env" filePath and populates the current environment with the values inside. Also returns the map object that contains all the environment variable keys along with their values that were present in the file. returnNilErrOnNoFile tells the function to ignore an error when the filePath given does not exist on the filesystem. This is useful in the case where loading the environment file contents isn't critical to the execution of the application.

Types

This section is empty.

Jump to

Keyboard shortcuts

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