/
githubmirror
/
LeetCode-Go
Обзор
Документация
Войти
/
githubmirror
/
LeetCode-Go
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
1.7.97
ctl/template_render.go
39 строк
711 B
halfrost
Fix ctl module
11 сен 2022, 05:20
11 сен 2022, 05:20
ce4286a
Код
Авторство
О чём код?
package main import ( "bytes" "fmt" "html/template" "io/ioutil" "os" m "github.com/halfrost/LeetCode-Go/ctl/models" "github.com/halfrost/LeetCode-Go/ctl/util" ) func makeReadmeFile(mdrows m.Mdrows) { file := "./README.md" os.Remove(file) var b bytes.Buffer tmpl := template.Must(template.New("readme").Parse(readTMPL("template.markdown"))) err := tmpl.Execute(&b, mdrows) if err != nil { fmt.Println(err) } // 保存 README.md 文件 util.WriteFile(file, b.Bytes()) } func readTMPL(path string) string { file, err := os.Open(path) if err != nil { fmt.Println(err) } defer file.Close() data, err := ioutil.ReadAll(file) if err != nil { fmt.Println(err) } return string(data) }