config

package module
v0.0.0-...-c3c0d16 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-config

Provides a standard configuration interface for golang projects

Usage

Put your configuration file under the folder specified by the environment variables CURRENT_CONFIG_NAME and CURRENT_CONFIG_PATH

Example

export CURRENT_CONFIG_NAME=config
export CURRENT_CONFIG_PATH=./config 

This is a sample of config/yaml file:

env:
    DB_CONNECTION_STRING: 'schema://user_name:password@host:5432/postgres'
    SOME_SETTING: value

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(configFiles ...string) (*viper.Viper, error)

Returns a type compliant with the Config interface

Types

type Config

type Config interface {
	BindPFlag(key string, flag *pflag.Flag) error
	BindPFlags(flags *pflag.FlagSet) error
	Get(key string) interface{}
	GetBool(key string) bool
	GetDuration(key string) time.Duration
	GetFloat64(key string) float64
	GetInt(key string) int
	GetInt32(key string) int32
	GetInt64(key string) int64
	GetIntSlice(key string) []int
	GetSizeInBytes(key string) uint
	GetString(key string) string
	GetStringMap(key string) map[string]interface{}
	GetStringMapString(key string) map[string]string
	GetStringMapStringSlice(key string) map[string][]string
	GetStringSlice(key string) []string
	GetTime(key string) time.Time
	GetUint(key string) uint
	GetUint32(key string) uint32
	GetUint64(key string) uint64
	IsSet(key string) bool
	AllSettings() map[string]interface{}
}

Interface defines getters for any config data type

Jump to

Keyboard shortcuts

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