37 lines
727 B
Go
37 lines
727 B
Go
|
// +build ignore
|
||
|
|
||
|
package main
|
||
|
|
||
|
import (
|
||
|
"encoding/base64"
|
||
|
"io/ioutil"
|
||
|
"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, "rootfs.go"))
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
tarPath := filepath.Join(wd, "image.tar")
|
||
|
|
||
|
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("\tDATA = `"))
|
||
|
f, err := ioutil.ReadFile(tarPath)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
|
||
|
tar := base64.StdEncoding.EncodeToString(f)
|
||
|
out.Write([]byte(tar))
|
||
|
|
||
|
out.Write([]byte("`\n"))
|
||
|
out.Write([]byte(")\n"))
|
||
|
}
|