config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Null   = gjson.Null
	False  = gjson.False
	Number = gjson.Number
	String = gjson.String
	True   = gjson.True
	JSON   = gjson.JSON
)

Variables

View Source
var (
	Description = "网站服务"
	Version     = "<unknown>"
	BuildTime   = "<unknown>"
	BuildHash   = "<unknown>"
	BuildTag    = "<unknown>"
)

Functions

func Coalesce added in v1.0.0

func Coalesce[T comparable](values ...T) (out T)

Coalesce returns the first non-zero arguments. Arguments must be comparable.

func Display

func Display()

func IifF

func IifF[T any](condition bool, ifFunc func() T, elseFunc func() T) T

IifF is a 1 line if/else statement whose options are functions

func IsDebug added in v1.0.0

func IsDebug() bool

func ReadJSONFile

func ReadJSONFile(path string, out any) (err error)

ReadJSONFile 从文件中解析配置

func ReadYAMLFile

func ReadYAMLFile[T any](path string, out *T) (err error)

ReadYAMLFile 从文件中解析配置

func SetDebug added in v1.0.0

func SetDebug(d bool)

func SetWorkSpace

func SetWorkSpace(ws string) error

func UnmarshalYAMLString

func UnmarshalYAMLString[T any](data string, out *T) (err error)

UnmarshalYAMLString 从字符串中解析配置

func WorkSpace

func WorkSpace(names ...string) string

WorkSpace 解析工作路径

func WriteJSONFile

func WriteJSONFile(path string, in any) (err error)

WriteJSONFile 将配置写入文件

func WriteYAMLFile

func WriteYAMLFile(path string, in any) (err error)

WriteYAMLFile 将配置写入文件

Types

type Type

type Type = gjson.Type

type Value

type Value = gjson.Result

func Get

func Get(name string, force ...bool) (out Value)

Get 获取配置

func ParseJSON

func ParseJSON[T ~string | ~[]byte](data T) Value

func YamlFileToJSON

func YamlFileToJSON(path string) (r Value)

YamlFileToJSON read yaml file, unmarshal it and convert to gjson value

Jump to

Keyboard shortcuts

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