kconfig

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2020 License: MIT Imports: 7 Imported by: 0

README

Kconfig

Yaml file my-file.yaml:

addr: ":8080"
database:
  dialect: "postgres"
  timeout: 12
list: 
  - "first"
  - "second"
  - "third"
gtm: "env[GTM_ENV]"

Usage:

import "github.com/krstak/kconfig"

c, err := kconfig.Load("./my-file.yaml")

// returns string ":8080"
c.Get("addr")

// returns string "postgres"
c.Get("database.dialect")

// returns int 12
c.GetInt("database.timeout")

// returns slice []string{"first", "second", "third"}
c.GetSlice("list")

// returns a value of environment variable GTM_ENV as a string
c.Get("gtm")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

func Load

func Load(path string) (Config, error)

func (Config) Get

func (c Config) Get(key string) string

func (Config) GetInt

func (c Config) GetInt(key string) int

func (Config) GetSlice

func (c Config) GetSlice(key string) []string

Jump to

Keyboard shortcuts

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