zenConfig

package module
v0.0.0-...-21f792c Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 6 Imported by: 0

README

Config

Config Getter

Config Getter support from .env or environment variable

Usage

Import the package

import (
    ...
    "github.com/hansvintsugata/go-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 := sunerConfig.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