yamlKit

package
v2.2.27 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Marshal func(in interface{}) (out []byte, err error) = yaml.Marshal

Marshal

PS: 需要搭配 yaml tag 一起使用,不识别 json tag.

View Source
var Unmarshal func(in []byte, out interface{}) (err error) = yaml.Unmarshal

Unmarshal

Deprecated: Use confKit.MustLoad || confKit.LoadFromYamlBytes instead.

PS: 需要搭配 yaml tag 一起使用,不识别 json tag.

Functions

func MarshalToFile added in v2.2.2

func MarshalToFile(in interface{}, filePath string) error

MarshalToFile

PS: (1) 需要搭配 yaml tag 一起使用,不识别 json tag. (2) 对 传参filePath 的验证和断言在 fileKit.WriteToFile 里面.

@param in 建议为结构体实例指针 || map实例 || slice实例 @param filePath (1) .yaml 格式的文件

(2) 不存在的话,会创建一个新的文件
(3) 存在且是个文件的话,会 "覆盖" 掉旧的(并不会加到该文件的最后面)

func MarshalToFileWithJsonTag added in v2.2.5

func MarshalToFileWithJsonTag(in interface{}, filePath string) error

MarshalToFileWithJsonTag

PS: (1) 适用场景: 有json tag,没有yaml tag. (2) 缺陷: (a) 传参in 不能为slice实例;

(b) map是无序的键值对集合,生成的yaml会有点乱(即使按照key排序);
(c) key中如果有大写字母,全部会变成小写字母.

func MarshalToString

func MarshalToString(in interface{}) (string, error)

MarshalToString

PS: 需要搭配 yaml tag 一起使用,不识别 json tag.

@param in 建议为结构体实例指针 || map实例 || slice实例

func UnmarshalFromString deprecated

func UnmarshalFromString(in string, out interface{}) error

UnmarshalFromString

Deprecated: Use confKit.MustLoad || confKit.LoadFromYamlBytes instead.

PS: 需要搭配 yaml tag 一起使用,不识别 json tag.

Types

This section is empty.

Jump to

Keyboard shortcuts

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