config

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: MIT Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigEnv = "CONFIG_FILE"

ConfigEnv specifies the env variable which contains the path to a config file. To use a different env variable, change this in an init block in your app.

Functions

This section is empty.

Types

type Module

type Module struct {
	Logger *logger.Module

	Byte       []byte
	Env        map[string]string
	ConfigPath string

	// TestConfigPath can be to load a specific config file in tests.
	// Alternatively, you can set Byte directly to the desired config
	// file contents.
	TestConfigPath string

	DisableChdir bool
	// contains filtered or unexported fields
}

Module for config package.

func (*Module) Getenv

func (m *Module) Getenv(key string) string

Getenv reads and caches env variable

func (*Module) Init

func (m *Module) Init(c *service.Config)

Init implements the module interface method

func (*Module) LoadConfig

func (m *Module) LoadConfig(path string) error

LoadConfig loads the config json file from the given path

func (*Module) PrintConsolidatedConfig

func (m *Module) PrintConsolidatedConfig()

PrintConsolidatedConfig prints out the definitions of all config

func (*Module) ReadConfig

func (m *Module) ReadConfig(i interface{}) error

ReadConfig json-decodes the config file bytes into i, which should be a pointer to a struct.

func (*Module) Resource added in v1.4.0

func (m *Module) Resource(resource string) ([]byte, error)

func (*Module) ResourcePath added in v1.4.0

func (m *Module) ResourcePath(resource string) (string, error)

Jump to

Keyboard shortcuts

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