cfg

package module
v0.0.0-...-5ed4f32 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2017 License: Apache-2.0 Imports: 9 Imported by: 7

README

cfg

Go library for working with app's configuration files used at Mailgun.

Usage

Define a struct representing a configuration file. Optional fields may be marked with config:"optional" tag, so if they're missing from the config file, no error will occur; by default all fields are mandatory. Builtin structs are also supported:

type Config struct {
  Keyspace string
  Servers  []string

  Builtin struct {
    Field string
  }

  PidPath string `config:"optional"`
}

Config file should be in YAML format and corresponding key names should match the ones in the defined struct:

keyspace: blah
servers:
  - server1
  - server2

builtin:
  field: value

Load config into a struct:

package main

import (
  "github.com/mailgun/cfg"
)

func main() {
  config := Config{}
  cfg.LoadConfig("path/to/config.yaml", &config)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(configPath string, configStruct interface{}) error

Types

type InValid

type InValid struct {
	Name string
	Type string
}

Jump to

Keyboard shortcuts

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