conf

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 9 Imported by: 1

README

conf

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


Example of use

    import "github.com/zhufuyi/sponge/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 is parsing yaml, json, toml configuration files to go struct.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

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

Parse configuration files to struct, including yaml, toml, json, etc., and turn on listening for configuration file changes if fs is not empty

func ParseConfigData added in v1.5.11

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

ParseConfigData parse data to struct

func Show

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

Show print configuration information (hide sensitive fields)

Types

This section is empty.

Jump to

Keyboard shortcuts

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