math-optim/report/gen.go
surtur 052b51f0df
All checks were successful
continuous-integration/drone/push Build is passing
go(report): rework gen.go,report.tmpl
make report include `report_base.tex` file verbatim and save it in
`out/tex/report.tex` as a base file of the report.

currently, this is done when running `go generate ./report` but there
are plans to switch from that to emitting the file during runtime, as is
done with all other templates.
2022-07-17 13:28:45 +02:00

49 lines
744 B
Go

// Copyright 2022 wanderer <a_mirre at utb dot cz>
// SPDX-License-Identifier: GPL-3.0-or-later
//go:build ignore
// +build ignore
package main
import (
_ "embed"
"log"
"os"
"text/template"
"time"
)
var (
//go:embed report_base.tex
reportBase []byte
//go:embed report.tmpl
tmplReportFile []byte
)
func main() {
fName := "../out/tex/report.tex"
f, err := os.Create(fName)
if err != nil {
log.Fatal(err)
}
defer f.Close()
tmplReport := template.New("report")
tmplReport = template.Must(tmplReport.Parse(string(tmplReportFile)))
err = tmplReport.Execute(f, struct {
ReportBase string
Timestamp time.Time
}{
ReportBase: string(reportBase),
Timestamp: time.Now(),
})
if err != nil {
log.Println(err)
}
}