migi

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2019 License: MIT Imports: 3 Imported by: 2

README

migi Build Status Coverage Status Go Report Card

A helper library to configure software runtime

dependencies

tools (you must provide the installation)

tests and coverage

  • run unit tests: make docker.test
  • run html coverage: make docker.coverage.html

migi usage

Find some samples in the test file a better usage section will be avaiable soon ...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewOptionInvalidType

func NewOptionInvalidType(name string, source interface{}, target string) error

func NewOptionNotFound

func NewOptionNotFound(name string) error

Types

type OptionInvalidType

type OptionInvalidType struct {
	Name   string
	Source interface{}
	Target string
}

func (OptionInvalidType) Error

func (e OptionInvalidType) Error() string

type OptionNotFound

type OptionNotFound struct {
	Name string
}

func (OptionNotFound) Error

func (e OptionNotFound) Error() string

type Options

type Options interface {
	String(name string, defaultValue string, description string) *string
	StringVar(pointer *string, name string, defaultValue string, description string)
	Int(name string, defaultValue int, description string) *int
	IntVar(pointer *int, name string, defaultValue int, description string)
	Bool(name string, defaultValue bool, description string) *bool
	BoolVar(pointer *bool, name string, defaultValue bool, description string)
	Float(name string, defaultValue float32, description string) *float32
	FloatVar(pointer *float32, name string, defaultValue float32, description string)
	Time(name string, defaultValue time.Time, description string) *time.Time
	TimeVar(pointer *time.Time, name string, defaultValue time.Time, description string)
	Duration(name string, defaultValue time.Duration, description string) *time.Duration
	DurationVar(pointer *time.Duration, name string, defaultValue time.Duration, description string)
	Load() error
}

Options is an interface wich provides access to software configuration

func NewOptions

func NewOptions(sources ...Source) Options

NewOptions creates an options instance with the provided sources

type Source

type Source interface {
	Load() error
	Bool(name string) (bool, error)
	Int(name string) (int, error)
	Float(name string) (float32, error)
	Time(name string) (time.Time, error)
	Duration(name string) (time.Duration, error)
	String(name string) (string, error)
}

Source is an interface to define how options are loaded

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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