9 Star 45 Fork 10

卧雪Sirk/gosk

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
yamlparser.go 658 Bytes
一键复制 编辑 原始数据 按行查看 历史
scottkiss 提交于 2014-01-20 21:49 +08:00 . first commit
package gosk
import (
"github.com/scottkiss/go-gypsy/yaml"
"log"
"os"
"strings"
)
type YamlParser struct{}
var YAML_FILES = [3]string{"config.yml", "pages.yml", "nav.yml"}
func (yp *YamlParser) parse(root string) map[string]interface{} {
var yamlFilesConfig = make(map[string]interface{})
if !strings.HasSuffix(root, "/") {
root += "/"
}
for _, yamlFile := range YAML_FILES {
path := root + yamlFile
if !isExists(path) {
log.Panic(path + " file not found!")
os.Exit(1)
}
config, err := yaml.ReadFile(path)
if err != nil {
log.Panic(err)
os.Exit(1)
}
yamlFilesConfig[yamlFile] = config
}
return yamlFilesConfig
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/scottkiss/gosk.git
git@gitee.com:scottkiss/gosk.git
scottkiss
gosk
gosk
master

搜索帮助