config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: MIT Imports: 11 Imported by: 0

README

Config

The config package provides a simple and efficient way to manage configuration in Go applications.

Features

  • Easy to use: The config package is designed to be simple and intuitive to use.
  • Flexible: It supports multiple configuration formats such as JSON, YAML, and TOML.
  • Environment variable support: You can easily override configuration values using environment variables.

Usage

Import the config package:

import "github.com/huahuayu/kit/config"

Create a new config instance and load a configuration file:

loader := NewConfigLoader[sampleConfig]()
cfg, err := loader.Load("testdata/sample.yaml", config.YAML)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileType

type FileType int
const (
	YAML FileType = iota
	TOML
	JSON
	DOTENV
)

type Loader

type Loader[T any] interface {
	LoadDefault(fn func() (T, error)) (T, error)
	Load(configPath string, fileType FileType) (T, error)
}

func NewConfigLoader

func NewConfigLoader[T any]() Loader[T]

Jump to

Keyboard shortcuts

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