1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
// +build ignore
package main
import (
"io"
"os"
"path/filepath"
)
// Reads static/index.html and saves as a constant in static.go
func main() {
wd, err := os.Getwd()
if err != nil {
panic(err)
}
out, err := os.Create(filepath.Join(wd, "static.go"))
if err != nil {
panic(err)
}
indexPath := filepath.Join(wd, "static", "index.html")
out.Write([]byte("// This file is autogenerated; DO NOT EDIT DIRECTLY\n// See generate.go for more info\npackage main\n\nconst (\n"))
out.Write([]byte("\tindexHtml = `"))
f, err := os.Open(indexPath)
if err != nil {
panic(err)
}
defer f.Close()
if _, err := io.Copy(out, f); err != nil {
panic(err)
}
out.Write([]byte("`\n"))
out.Write([]byte(")\n"))
}
|