settings

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

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

Go to latest
Published: Mar 15, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

README

golangci-lint logo

settings

Settings Loader


settings package that allows you to load settings from ENV, files (JSON, TOML, YAML, etc.) and also set default values for structure fields.


Install settings

  1. Load the package into the project
go get github.com/auvitly/settings
  1. Import the package at the place of use
import "github.com/auvitly/settings"

Documentation

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadOptions

func LoadOptions(name string, paths ...string) (*viper.Viper, error)

LoadOptions - функция загружает viper из файла

func LoadSettings

func LoadSettings(settings interface{}, v *viper.Viper) error

LoadSettings - установка значения из viper в структуру, указатель на которую передается в качестве аргумента

func SetOption

func SetOption(options types.Options, value interface{}) error

SetOption - настройка конфигуратора

Types

type IConfigurator

type IConfigurator interface {
	// ReadOptions - загрузка viper из внешнего reader
	ReadOptions(config io.Reader) error
	// LoadOptions - загрузка viper из файла, который был установлен при создании конфигуратора
	LoadOptions() error
	// LoadSettings - установка значения из viper в структуру, указатель на которую передается в качестве аргумента
	LoadSettings(config interface{}) error
	// SetOption - настройка конфигуратора
	SetOption(options types.Options, value interface{}) error
}

func New

func New(name string, paths ...string) IConfigurator

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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