script: Use strings instead of byte slice literals in asset generation

It compiles literally 50 times faster and generates the same code. Also
add the little header that indicates auto generated code.
This commit is contained in:
Jakob Borg 2018-06-13 23:43:16 +02:00
parent 7b47692ec0
commit 793b86e604

View File

@ -23,7 +23,9 @@ import (
"time"
)
var tpl = template.Must(template.New("assets").Parse(`package auto
var tpl = template.Must(template.New("assets").Parse(`// Code generated by genassets.go - DO NOT EDIT.
package auto
const Generated int64 = {{.Generated}}
@ -70,7 +72,7 @@ func walkerFor(basePath string) filepath.WalkFunc {
name, _ = filepath.Rel(basePath, name)
assets = append(assets, asset{
Name: filepath.ToSlash(name),
Data: fmt.Sprintf("%#v", buf.Bytes()), // "[]byte{0x00, 0x01, ...}"
Data: fmt.Sprintf("[]byte(%q)", buf.String()),
})
}