将 YAML 转换为 JSON。
安装
go get -u github.com/peter-edge/go-yaml2json
进口
import (
"github.com/peter-edge/go-yaml2json"
)
灵感来自 ,一个具有相同效果的命令行工具。
import (
"encoding/json"
"io/ioutil"
"os"
"github.com/peter-edge/go-yaml2json"
)
func ReadYamlToJson(yamlFilePath string) (interface{}, error) {
yamlFile, err := os.Open(yamlFilePath)
if err != nil {
return nil, err
}
defer yamlFile.Close()
ya
2021-11-24 17:57:46
6KB
Go
1