conf

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2018 License: MIT Imports: 2 Imported by: 8

README

conf

GoDoc Build Status Go Report Card

Package conf loads configuration sections from different sources and merges them into the one configuration tree. See documentation on GoDoc for more information.

Documentation

Overview

Package conf loads configuration sections from different sources and merges them into the one configuration tree.

package main

import (
  "fmt"
  "os"

  "github.com/iph0/conf"
  "github.com/iph0/conf/baseconf"
)

func init() {
  os.Setenv("GOCONF_PATH", "/etc/go")
}

func main() {
  loader := conf.NewLoader(
    baseconf.NewDriver(),
  )

  config, err := loader.Load("dirs", "db")

  if err != nil {
    fmt.Println("Loading failed:", err)
    return
  }

  fmt.Printf("%v\n", config)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver interface {
	Load(string) (map[string]interface{}, error)
}

Driver interface is the interface for all configuration loader drivers.

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

Loader loads configuration sections from different sources using different loader drivers.

func NewLoader

func NewLoader(drivers ...Driver) *Loader

NewLoader method creates a new configuration loader.

func (*Loader) Load

func (l *Loader) Load(sections ...interface{}) (map[string]interface{}, error)

Load method loads configuration sections and merges them to the one configuration tree. Configuration section can be specified as a string or as a map[string]interface{}

Directories

Path Synopsis
Package baseconf is the loader driver for the conf package, that loads configuration data from YAML and JSON files.
Package baseconf is the loader driver for the conf package, that loads configuration data from YAML and JSON files.
Package merger recursively merge two data structures into new one.
Package merger recursively merge two data structures into new one.

Jump to

Keyboard shortcuts

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