config

package module
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 3 Imported by: 7

README

Darvaza Config

Go Reference Go Report Card

darvaza.org/x/config provides helpers for dealing with config files.

Default values

Wrappers for github.com/amery/defaults:

  • SetDefaults()
  • Set()
  • CanUpdate()

Environment

Expand shell-style variables:

  • FromString()
  • FromBytes()
  • FromReader()
  • FromFile()

Validations

Wrappers for github.com/go-playground/validator/v10:

  • Validate()
  • AsValidationError()
  • and Prepare(). calling SetDefaults() and Validate().

See also

Documentation

Overview

Package config provides helpers for handling config structs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsValidationErrors

func AsValidationErrors(err error) (validator.ValidationErrors, bool)

AsValidationErrors gives access to a slice of validator.FieldError

func CanUpdate

func CanUpdate(v any) bool

CanUpdate returns true when the given value is an initial value of its type

func Prepare

func Prepare(v any) error

Prepare runs SetDefaults and Validate

func Set

func Set(v any) error

Set applies `default` struct-tags and SetDefaults() recursively. If the given object has a `SetDefaults() error` method, it will be ignored. Any `SetDefaults() error` deeper in the struct will be called.

func SetDefaults

func SetDefaults(v any) error

SetDefaults applies `default` struct-tags and SetDefaults() recursively. If the given object has a `SetDefaults() error` method, it will be invoked instead.

func Validate

func Validate(v any) error

Validate validates exposed fields including nested structs

Types

This section is empty.

Directories

Path Synopsis
Package expand implements helpers to expand shell-style variables within config files before they are parsed
Package expand implements helpers to expand shell-style variables within config files before they are parsed

Jump to

Keyboard shortcuts

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