Categorygithub.com/tommzn/go-config
modulepackage
1.2.1
Repository: https://github.com/tommzn/go-config.git
Documentation: pkg.go.dev

# README

Go Reference GitHub go.mod Go version GitHub release (latest by date) Go Report Card Actions Status

Read & Access Configurations

Provides different sources to read config and a generic interface to access configurations. Under the hood it used ![Viper Config]/https://github.com/spf13/viper) to load, parse and access configurations.

Sources

Following sources are available:

  • local/static config
  • config from YAML files
  • config from files stored in AWS S3 bucket

# Functions

AsBoolPtr returns given value as pointer.
AsDuration will try to convert passed string to time.Duration.
AsDurationPtr returns given value as pointer.
AsIntPtr will return passed int value as pointer.
AsStringPtr return given value as pointer.
NewConfigSource returns the default config loader, the ViperConfigSource.
NewFileConfigSource returns a new config source for given file.
NewS3ConfigSource returns a new S3 config source which uses passed config file from given S4 bucket.
NewS3ConfigSourceFromEnv creates a new S3 config source using values defined by environment variables.
NewStaticConfigSource returns source with given static config values.
SetViperConfigType sets the config type which should be used at creating new viper config.

# Structs

FileConfigSource reads a config file in YAML format using viper config.
S3ConfigSource loads a YAML config from a file in a AWS S3 bucket.
StaticConfigSource uses a static config passed during creating this config source.
ViperConfig is a wrapper to config handler provided by github.com/spf13/viper.

# Interfaces

Config is the ain interface provides by this package to get an access point for config from different sources and formats.
ConfigSource can be used to load a config from different sources and with different formats.