external

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 5 Imported by: 0

README

External

This package provides implementations of External option for EnvConf parsing process.

Implement your own external or use any of already implemented

Usage

	json := `{"foo":"bar"}`
	tc := struct {
		Foo string `env:"ENV_FOO"`
	}{}
	err := envconf.Parse(&tc, 
        option.WithExternal(jsonconf.Json([]byte(json))))

If env variable is it not specified for Foo variable, EnvConf will define it from json input.

Wrapped external

  • json (encoding/json)
  • yaml (gopkg.in/yaml.v3)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type External added in v1.4.0

type External interface {
	// TagName is key name in golang struct tag (json, yaml, toml etc.).
	TagName() []string
	// Unmarshal parses the external data and stores the result
	// in the value pointed to by v.
	// Usually, it just wraps the existing `Unmarshal` function of third-party libraries
	Unmarshal(v interface{}) error
}

External config source Implementation of this interface should be able to `Unmarshal` data into map[string]interface{}, where interface{} should be also same map type for the nested structures

type ExternalConfigMapper added in v1.4.0

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

func NewExternalConfigMapper added in v1.4.0

func NewExternalConfigMapper(ext External) *ExternalConfigMapper

func (*ExternalConfigMapper) Data added in v1.4.0

func (*ExternalConfigMapper) Unmarshal added in v1.4.0

func (c *ExternalConfigMapper) Unmarshal(v interface{}) error

type ExternalSource added in v1.4.0

type ExternalSource interface {
	Read(string) (interface{}, bool)
}

func AsExternalSource added in v1.4.0

func AsExternalSource(name string, es ExternalSource) ExternalSource

type NilContainer added in v1.4.0

type NilContainer struct{}

func (NilContainer) Read added in v1.4.0

func (NilContainer) Read(index string) (interface{}, bool)

Directories

Path Synopsis
yaml module

Jump to

Keyboard shortcuts

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