configure

package module
v0.0.0-...-4e58735 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: BSD-3-Clause Imports: 11 Imported by: 0

README

configure

Latest release Build status Go Report Card Documentation

Package configure.

go get github.com/go-pogo/configure
import "github.com/go-pogo/configure"

Documentation

Additional detailed documentation is available at pkg.go.dev

Created with

License

Copyright © 2021 Roel Schut. All rights reserved.

This project is governed by a BSD-style license that can be found in the LICENSE file.

Documentation

Index

Constants

View Source
const ErrStructPointerExpected = internal.ErrStructPointerExpected

Variables

This section is empty.

Functions

This section is empty.

Types

type Conf

type Conf struct {
	// contains filtered or unexported fields
}

func Configure

func Configure(v interface{}, proc ...Configurer) (*Conf, error)

func MustConfigure

func MustConfigure(v interface{}, proc ...Configurer) *Conf

MustConfigure calls Configure and handles any possible returned error from it, resulting in either: - no error; - an exit of the program if Configure returns a cli.FlagError; - a panic on all other non-nil returned errors.

func New

func New(proc ...Configurer) *Conf

func (*Conf) Configure

func (c *Conf) Configure(v interface{}) error

type Configurer

type Configurer interface {
	Configure(v interface{}) error
}

A Configurer can

func Data

func Data(data []byte, dec DecoderFunc) Configurer

Data wraps the data in a bytes.Buffer and sends it to Read.

func File

func File(path string, dec DecoderFunc) Configurer

File reads a file and decodes its data stream with the provided decoder. It expects the file to exist and returns an error when it cannot be opened.

func FileFS

func FileFS(fsys fs.FS, path string, dec DecoderFunc) Configurer

FileFS reads a file from a fs.FS and decodes its data stream with the provided decoder. It expects the file to exist and returns an error when it cannot be opened.

func Read

func Read(r io.Reader, dec DecoderFunc) Configurer

Read from io.Reader r and decode the data stream with the provided decoder.

func TryFile

func TryFile(path string, dec DecoderFunc) Configurer

TryFile tries to read a file and decodes its data stream with the provided decoder. It won't return an error if the file cannot be opened.

func TryFileFS

func TryFileFS(fsys fs.FS, path string, dec DecoderFunc) Configurer

TryFileFS tries to read a file from a fs.FS and decodes its data stream with the provided decoder. It won't return an error if the file cannot be opened.

type ConfigurerFunc

type ConfigurerFunc func(v interface{}) error

func (ConfigurerFunc) Configure

func (f ConfigurerFunc) Configure(v interface{}) error

type DecoderFunc

type DecoderFunc func(r io.Reader, v interface{}) error

type Secret

type Secret string

Secret can be either a string containing the secret or a file to read the secret string from. This is particularly useful when used with docker swarm secrets. See https://docs.docker.com/engine/swarm/secrets/ for additional information.

func (Secret) GoString

func (s Secret) GoString() string

func (Secret) IsPath

func (s Secret) IsPath() bool

IsPath returns true if Secret is a path to a secrets file, otherwise it returns false. It does not verify if a file exists or is readable.

func (Secret) ReadBytes

func (s Secret) ReadBytes() ([]byte, error)

ReadBytes returns the content of Secret as bytes.

func (Secret) ReadString

func (s Secret) ReadString() (string, error)

ReadString returns the content of Secret as string.

func (Secret) String

func (s Secret) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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