1 Star 0 Fork 32

伍圆/vik8s

forked from haiker/vik8s 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
yamls.go 1.15 KB
一键复制 编辑 原始数据 按行查看 历史
haiker 提交于 2020-06-24 18:09 . 0.2开源版本正式发布
package main
import (
"bytes"
"fmt"
"github.com/ihaiker/vik8s/libs/utils"
"io/ioutil"
"os"
"path/filepath"
"sort"
)
//-- go:generate go get -u github.com/shuLhan/go-bindata/cmd/go-bindata
//go:generate go run yamls.go ${FILE}
//go:generate go-bindata -modtime 1590460659 -pkg yamls -o yaml/assets.go -ignore .*\.go -ignore .*\.part yaml/...
//go:generate go fmt yaml/assets.go
//碎片文件合并
func main() {
dir, err := filepath.Abs(os.Args[1])
utils.Panic(err, "path not found")
_ = filepath.Walk(filepath.Join(dir, "yaml"), func(path string, info os.FileInfo, err error) error {
if info.IsDir() && filepath.Ext(path) == ".part" {
mergeFileName := path[0:len(path)-5] + ".yaml"
dir, _ := os.Open(path)
names, _ := dir.Readdirnames(0)
sort.Strings(names)
writer := bytes.NewBufferString("")
for _, name := range names {
if filepath.Ext(name) != ".yaml" {
continue
}
writer.WriteString(fmt.Sprintf("# name %s\n---\n", name))
bs, _ := ioutil.ReadFile(filepath.Join(path, name))
writer.Write(bs)
writer.WriteString("\n\n")
}
return ioutil.WriteFile(mergeFileName, writer.Bytes(), 0644)
}
return nil
})
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/wuyuan/vik8s.git
git@gitee.com:wuyuan/vik8s.git
wuyuan
vik8s
vik8s
master

搜索帮助