config

package
v0.0.0-...-5bf8bb3 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2018 License: MIT Imports: 1 Imported by: 0

README

Config

Package config allows other packages to require a certain section of TOML configuration file to be parsed into its internal configuration structure. Once config file is processed its values are distributed by the packages that required them.

import "github.com/localhots/gobelt/config"

Describe configuration structure inside a target package then call config.Require from the init function of a package.

Note: subgroups are not currently supported. If a package is called s3 and located in aws parent package, call config section aws_s3 instead of aws.s3.

package db

var conf struct {
    Flavor string `toml:"flavor"`
    DSN    string `toml:"dsn"`
}

func init() {
    config.Require("db", &conf)
}

Load configuration from a main function of the app:

package main

func main() {
    config.Load("config/config.toml")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(src string) error

Load ...

func LoadFile

func LoadFile(path string) error

LoadFile reads the config file and distributes provided configuration to requested destinations.

func Require

func Require(key string, dest interface{})

Require registers a request for package configuration.

Types

This section is empty.

Jump to

Keyboard shortcuts

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