config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config provides an application configuration loader base on konf.

Configuration Sources

It loads configuration from the following sources, and each source takes precedence over the sources below it:

  • environment variables which matches the following pattern: prefix + "_" + key, all in ALL CAPS. For example, FOO_BAR is the name of environment variable for configuration `foo.bar`.
  • config files specified by WithFS and WithFile. WithFile also can be overridden by the environment variable `CONFIG_FILE`. For example, if CONFIG_FILE = "f1, f2,f3", it will load f1, f2, and f3, and each file takes precedence over the files before it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...Option) (*konf.Config, error)

New creates a new konf.Config with the given Option(s).

Types

type Option

type Option func(*options)

Option configures the config with specific options.

func WithFS

func WithFS(fs fs.FS) Option

WithFS provides the fs.FS to load the config files from.

By default, it uses OS file system under the current directory.

func WithFile

func WithFile(files ...string) Option

WithFile explicitly provides the config file paths, and each file takes precedence over the files before it.

By default, it uses "config/config.yaml". It can be overridden by the environment variable "CONFIG_FILE".

func WithOption

func WithOption(opts ...konf.Option) Option

WithOption provides the konf.Option to customize the config.

Jump to

Keyboard shortcuts

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