yamlKit

package
v3.0.81 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: Apache-2.0 Imports: 3 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

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

Functions

func MarshalToFile

func MarshalToFile(in interface{}, filePath string, perm os.FileMode) error

MarshalToFile

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

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

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

func MarshalToString

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

MarshalToString

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

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

func UnmarshalFromFile added in v3.0.18

func UnmarshalFromFile(path string, out interface{}) error

func UnmarshalFromString

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

UnmarshalFromString

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