pconfig

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCacheValue added in v0.0.7

func GetCacheValue(filePath string, keyPath string) string

GetCacheValue reads a string value from a JSON file using a dot-separated key path. Returns empty string if file doesn't exist or key not found.

func GetDefaultCachePath added in v0.0.7

func GetDefaultCachePath() string

func GetInt32D added in v0.0.5

func GetInt32D(key string, defaultVal int32) int32

--------------------------------------------------

func GetInt32E added in v0.0.5

func GetInt32E(key string) (int32, error)

func GetInt32M added in v0.0.5

func GetInt32M(key string) int32

func GetInt64D

func GetInt64D(key string, defaultVal int64) int64

--------------------------------------------------

func GetInt64E

func GetInt64E(key string) (int64, error)

func GetInt64M

func GetInt64M(key string) int64

func GetStringD

func GetStringD(key string, defaultVal string) string

--------------------------------------------------

func GetStringE

func GetStringE(key string) (string, error)

func GetStringM

func GetStringM(key string) string

func Has added in v0.0.7

func Has(key string) bool

Has 检查配置是否存在

func InitConfig

func InitConfig(paths ...string) (err error)

InitConfig 初始化配置 paths: 可以指定一个或多个配置文件路径, 如果是目录,则会尝试加载common.toml和执行文件名的toml 如果没有指定路径,则默认加载当前执行文件所在目录下的configs目录中的配置

func MustGetConfig

func MustGetConfig() config.Config

func MustInitConfig

func MustInitConfig(paths ...string)

same as InitConfig, but panic if error occurs

func Scan

func Scan(v any) (err error)

支持定义结构体来解析配置

func SetCacheValue added in v0.0.7

func SetCacheValue(filePath string, keyPath string, value string) error

SetCacheValue writes a string value to a JSON file using a dot-separated key path. Creates the file and directories if they don't exist.

func SetDefaults

func SetDefaults(ptr any) error

-------------------------------------------------- 支持代码配置默认值,支持字符串/整形/浮点型/布尔型 通过Tag如`default:"10"`来设置默认值,值都使用字符串来填写

Types

This section is empty.

Jump to

Keyboard shortcuts

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