tomlenv

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2022 License: MIT Imports: 3 Imported by: 0

README

TOMLenv

This simple package will read all the variables from your .toml file and put them in the environment so you can easily access them via os.Getenv("varname").

Installation

go get -u github.com/vblinden/tomlenv

Example

env.toml

token = "abcdef123456"

[database]
username = "john"
password = "secret"

main.go

package main

import "github.com/vblinden/tomlenv"

func main() {
    // To load a file with name "env.toml"...
    tomlenv.Load()

    // To load a file with other names...
    tomlenv.LoadFile("custom.toml")

    // To load a string...
    tomlenv.LoadString("token = \"supersecret\"")

    // Will print "abcdef123456"...
    fmt.Printf(os.Getenv("token"))
    
    // To load a string...
    tomlenv.LoadString("[database]  username = \"john\"")

    // Will print "john"...
    fmt.Printf(os.Getenv("database.username"))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load() error

Load the default "env.toml" into your environment

func LoadFile

func LoadFile(filenames ...string) error

LoadFile wil load one or multiple files into your environment

func LoadString

func LoadString(content string) error

LoadString will load environment in based on a given TOML string

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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