config

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package config is used to initialize the configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertOptsToCliFlags

func ConvertOptsToCliFlags(groups ...string) []cli.Flag

ConvertOptsToCliFlags the config group to []cli.Flag. For example,

ConvertOptsToCliFlags()                   // Convert the options in the DEFAULT group
ConvertOptsToCliFlags("group1")           // Convert the options in the group named "group1"
ConvertOptsToCliFlags("group1.group2")    // Convert the options in the group named "group1.group2"
ConvertOptsToCliFlags("group1", "group2") // The same as the last.

func GetAllConfigs added in v0.16.0

func GetAllConfigs(conf *Config) (opts map[string]interface{})

GetAllConfigs returns all the registered configuration options.

If conf is equal to nil, it uses gconf.Conf as the default.

func InitConfig

func InitConfig(app string, options interface{}, version ...string)

InitConfig initliazlies the configuration options.

options may be gconf.Opt, []gconf.Opt, a pointer to the struct variable, or the list of the pointers to the struct variables. For example,

InitConfig("", gconf.StrOpt("optname", "HELP TEXT"))
InitConfig("appname", []gconf.Opt{gconf.StrOpt("optname", "HELP TEXT")})
InitConfig("", []interface{}{structPtr1, structPtr2}, "1.0.0")
InitConfig("", structPtr, "1.0.0")

func LoadCliSource

func LoadCliSource(ctx *cli.Context, groups ...string)

LoadCliSource loads the config into the groups from the CLI source.

Types

type Config added in v0.16.0

type Config = gconf.Config

Config is the alias of gconf.Config.

Jump to

Keyboard shortcuts

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