configoro

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2020 License: MIT Imports: 5 Imported by: 0

README

Configuration object to use in apps.

How to use:

go get github.com/Kamva/configoro

TODO List

  • Write tests
  • Write example of usage.
  • CI

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "1.0.0"

Version is the configoro version.

Functions

func DefaultEnvViper

func DefaultEnvViper(configStruct interface{}, envPrefix string, file string) (*viper.Viper, error)

defaultViper make new instance of viper with config to read from .env file. file is absolute string path of file. e.g `configoro.SourcePath()+"../.env"`

func SourcePath

func SourcePath() string

SourcePath returns the directory containing the source code that is calling this function.

Types

type AfterLoadHook

type AfterLoadHook interface {
	AfterLoad() error
}

AfterLoadHook calls after loading config.

type BeforeLoadHook

type BeforeLoadHook interface {
	BeforeLoad() error
}

BeforeLoadHook calls before loading config.

type Config

type Config interface {
	// Load function load config into config instance. pass instance by reference.
	Load(configInstance interface{}) error

	// Env function return environment value.
	Env(key string) string

	// Env function return environment value with default value.
	EnvDefault(key, def string) string
}

Config is config interface that should embed in each Config object.

func NewConfig

func NewConfig(viper *viper.Viper) Config

Directories

Path Synopsis
examples
internal

Jump to

Keyboard shortcuts

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