config

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 11 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 Display

func Display()

func Iif

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

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

func IifF

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

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

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 Select

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

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

func SetWorkSpace

func SetWorkSpace(ws string)

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