conf

package
v1.1.47 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: MIT Imports: 9 Imported by: 0

README

conf

Parsing yaml, json, toml configuration files to go struct.


Example of use

    import "github.com/18721889353/sunshine/pkg/conf"

    // Way 1: No listening configuration file
    config := &App{}
    err := conf.Parse("test.yml", config)

    // Way 2: Enable listening configuration file
    config := &App{}
    reloads  := []func(){
        func() {
            fmt.Println("close and reconnect mysql")
            fmt.Println("close and reconnect redis")
        },
    }
    err := conf.Parse("test.yml", config, reloads...)

Documentation

Overview

Package conf 是解析 YAML、JSON、TOML 配置文件到 Go 结构体的包。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(configFile string, obj interface{}, reloads ...func()) error

Parse 解析配置文件到结构体,支持 YAML、TOML、JSON 等格式,并且如果提供了 reload 函数,则开启监听配置文件变化

func ParseConfigData

func ParseConfigData(data []byte, format string, obj interface{}) error

ParseConfigData 解析数据到结构体

func Show

func Show(obj interface{}, fields ...string) string

Show 打印配置信息(隐藏敏感字段)

Types

This section is empty.

Jump to

Keyboard shortcuts

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