config

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2020 License: MIT Imports: 9 Imported by: 0

README

Build Status codecov HitCount

Config

Friendly GO YAML, JSON and TOML Configuration loader.

Installation

go get github.com/anjulapaulus/config

Usage

Folder Structure

config/
    config.yaml
    config.json
    config.toml
main.go

Implementation

import (
	"fmt"
	"github.com/anjulapaulus/config"
)

import (
	"fmt"
	"github.com/anjulapaulus/config"
)

type Config struct {
	APPName string `yaml:"appname"`

}

func main() {
    #if you want to strictly check on unmatched keys in config file
    #else false
	config.LoadConfig("config","config.yaml",&Config,true)
	fmt.Println(Cfg.APPName)
}

Benchmarks

go test -bench=Read reader_test.go parser.go reader.go parser_test.go

goos: darwin
goarch: amd64
BenchmarkReadFile-8                10000            113305 ns/op
PASS
ok      command-line-arguments  1.308s

go test -bench=Load reader_test.go parser.go reader.go parser_test.go

goos: darwin
goarch: amd64
BenchmarkLoadConfig-8              10000            111349 ns/op
BenchmarkLoad-8                    10000            110499 ns/op
PASS
ok      command-line-arguments  2.382s

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(folderName string, fileName string, config interface{}, checkUnmatchedKeys bool) (err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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