xonfig

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: MIT Imports: 3 Imported by: 0

README

xonfig

Load configuration from environment variables. Simple, strict.

Example

package main

import (
	"github.com/gin-gonic/gin"
	_ "github.com/joho/godotenv/autoload"
	_ "github.com/mattn/go-sqlite3"
	"github.com/nixberg/xonfig-go"
)

func main() {
	var config struct {
		DatabasePath  string `env:"DATABASE_PATH"`
		GinMode       string `env:"GIN_MODE"`
		ListenAddress string `env:"LISTEN_ADDRESS"`
	}
	xonfig.MustLoad(&config)

	db, err := sql.Open("sqlite3", config.DatabasePath)

	gin.SetMode(config.GinMode)
	router := gin.Default()

	router.Run(config.ListenAddress)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustLoad

func MustLoad(config interface{})

Types

This section is empty.

Jump to

Keyboard shortcuts

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