leafConfig

package module
v0.0.0-...-0829b1e Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: MIT Imports: 6 Imported by: 2

README

Config

Config Getter

Config Getter support from .env or environment variable

Usage

Import the package

import (
    ...
    "github.com/paulusrobin/leaf-utilities/config"
    ...
)

Create config struct

type (
    AppConfig struct {
        // - Interface Setting
        HttpEnable      bool `envconfig:"INTERFACE_HTTP_ENABLE" default:"true"`
        MessagingEnable bool `envconfig:"INTERFACE_MESSAGING_ENABLE" default:"true"`
        WorkerEnable    bool `envconfig:"INTERFACE_WORKER_ENABLE" default:"true"`
    }
)

Retrieve environment variable to struct

configuration := AppConfig{}
if err := leafConfig.NewFromEnv(&configuration); err != nil {
	return AppConfig{}, err
}
return configuration, nil

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(path string, configType string, object interface{}) error

func NewFromEnv

func NewFromEnv(object interface{}) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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