cfg

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package cfg provides a simple facility for loading configuration file. If there is an error, it will panic because handling configuration file errors is meaningless.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(x any) bool

Bool converts x to bool.

func ExecDir

func ExecDir() string

ExecDir returns the directory of the executable that started the current process.

func Float

func Float(x any) float64

Float converts x to float.

func HomeDir

func HomeDir() string

HomeDir returns the current user's home directory.

func Int

func Int(x any) int

Int converts x to int.

func String

func String(x any) string

String converts x to string.

Types

type Section

type Section struct {
	// contains filtered or unexported fields
}

Section represents a configuration section.

func Load

func Load(elems ...string) Section

Load loads configuration from file.

func (Section) BoolDict

func (a Section) BoolDict(key string) map[string]bool

BoolDict returns bool dict by key.

func (Section) BoolList

func (a Section) BoolList(key string) []bool

BoolList returns bool list by key.

func (Section) BoolValue

func (a Section) BoolValue(key string) bool

BoolValue returns bool value by key.

func (Section) FloatDict

func (a Section) FloatDict(key string) map[string]float64

FloatDict returns float dict by key.

func (Section) FloatList

func (a Section) FloatList(key string) []float64

FloatList returns float list by key.

func (Section) FloatValue

func (a Section) FloatValue(key string) float64

FloatValue returns float value by key.

func (Section) IntDict

func (a Section) IntDict(key string) map[string]int

IntDict returns int dict by key.

func (Section) IntList

func (a Section) IntList(key string) []int

IntList returns int list by key.

func (Section) IntValue

func (a Section) IntValue(key string) int

IntValue returns int value by key.

func (Section) Section

func (a Section) Section(key string) Section

Section returns the section by key.

func (Section) StringDict

func (a Section) StringDict(key string) map[string]string

StringDict returns string dict by key.

func (Section) StringList

func (a Section) StringList(key string) []string

StringList returns string list by key.

func (Section) StringValue

func (a Section) StringValue(key string) string

StringValue returns string value by key.

Jump to

Keyboard shortcuts

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