dotenv

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: MIT Imports: 1 Imported by: 0

README

dotenv

A simple .env file loader for go(golang)

Test

Install

go get github.com/radulucut/dotenv

Usage

.env

MY_VAR=some value
SECRET_KEY="s3cret"
SINGLE_QUOTE='some "value"'

main.go

package main

import (
	"log"
	"os"

	"github.com/radulucut/dotenv"
)

func main() {
	err := dotenv.Load(".env")
	if err != nil {
		log.Fatal("Error loading .env file")
	}

	myVar := os.Getenv("MY_VAR")
	secretKey := os.Getenv("SECRET_KEY")
	singleQuote := os.Getenv("SINGLE_QUOTE")

	// ...
}
Notes:
  • Overrides existing variables
  • Does not trim spaces
  • Does not support comments

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(filename string) error

Reads your env file and loads it into ENV for this process.

It overrides existing variables

Types

This section is empty.

Jump to

Keyboard shortcuts

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