cfg

package module
v0.0.0-...-71947a0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

README

系统配置文件读取

通过Get()获取配置Hash表。
通过Reload()函数重新载入config.ini.

Documentation

Overview

Package ini provides functions for parsing INI configuration files.

Index

Constants

View Source
const (
	LOG_DEBUG = 0
	LOG_INFO  = 1
	LOG_WARN  = 2
	LOG_ERROR = 3
	LOG_FATAL = 4
)
View Source
const (
	Llongfile  = 1 << iota // log调用者路径
	Lshortfile             // log调用者文件名
	Lfuncname              // 调用函数名
	LerrorExit             // error log关闭程序
	Lfilemask  = Llongfile | Lshortfile | Lfuncname
)
View Source
const (
	LDM_NONE  = 0
	LDM_ALL   = 1
	LDM_QUEST = 2
	LDM_LOGIN = 3
)

debug模块定义

Variables

View Source
var (
	LOGFILE_MAXSIZE_DEFAULT int64 = 50 << 20
)

Functions

func FileExist

func FileExist(filename string) bool

func Get

func Get(name string) map[string]string

func GetLogLevel

func GetLogLevel() int

func GetLogger

func GetLogger(typ string) *log.Logger

func InitLogLevel

func InitLogLevel(lv int)

func InitLogger

func InitLogger(pathParam, logfile string, maxSize int64)

func LogDebug

func LogDebug(v ...interface{})

func LogDebugc

func LogDebugc(calldepth int, v ...interface{})

func LogDebugf

func LogDebugf(format string, v ...interface{})

func LogErr

func LogErr(v ...interface{})

func LogErrc

func LogErrc(calldepth int, v ...interface{})

func LogErrf

func LogErrf(format string, v ...interface{})

func LogFatal

func LogFatal(v ...interface{})

func LogFatalc

func LogFatalc(calldepth int, v ...interface{})

func LogFatalf

func LogFatalf(format string, v ...interface{})

func LogInfo

func LogInfo(v ...interface{})

func LogInfoc

func LogInfoc(calldepth int, v ...interface{})

func LogInfof

func LogInfof(format string, v ...interface{})

func LogWarn

func LogWarn(v ...interface{})

func LogWarnc

func LogWarnc(calldepth int, v ...interface{})

func LogWarnf

func LogWarnf(format string, v ...interface{})

func OpenLogFile

func OpenLogFile(name string, flag int, perm os.FileMode) (file *logFile, err error)

func Reload

func Reload()

Types

type ErrSyntax

type ErrSyntax struct {
	Line   int
	Source string // The contents of the erroneous line, without leading or trailing whitespace
}

ErrSyntax is returned when there is a syntax error in an INI file.

func (ErrSyntax) Error

func (e ErrSyntax) Error() string

type File

type File map[string]Section

A File represents a parsed INI file.

func Load

func Load(in io.Reader) (File, error)

Loads and returns a File from a reader.

func LoadFile

func LoadFile(filename string) (File, error)

Loads and returns an INI File from a file on disk.

func (File) Get

func (f File) Get(section, key string) (value string, ok bool)

Looks up a value for a key in a section and returns that value, along with a boolean result similar to a map lookup.

func (File) Load

func (f File) Load(in io.Reader) (err error)

Loads INI data from a reader and stores the data in the File.

func (File) LoadFile

func (f File) LoadFile(file string) (err error)

Loads INI data from a named file and stores the data in the File.

func (File) Section

func (f File) Section(name string) Section

Returns a named Section. A Section will be created if one does not already exist for the given name.

type Section

type Section map[string]string

A Section represents a single section of an INI file.

Jump to

Keyboard shortcuts

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