aboutsummaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorJakob Borg <jakob@kastelo.net>2018-06-13 23:43:16 +0200
committerJakob Borg <jakob@kastelo.net>2018-06-13 23:48:50 +0200
commit793b86e6040299778c245c525d7f4720a6998d0f (patch)
tree5c1bd2645880b648f4487469f239792bd265143a /script
parent7b47692ec0daa1802d265fa1dd408a45a3a5872c (diff)
downloadsyncthing-793b86e6040299778c245c525d7f4720a6998d0f.tar.gz
syncthing-793b86e6040299778c245c525d7f4720a6998d0f.zip
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.
Diffstat (limited to 'script')
-rw-r--r--script/genassets.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/script/genassets.go b/script/genassets.go
index 5d0dfbc14..33b114109 100644
--- a/script/genassets.go
+++ b/script/genassets.go
@@ -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()),
})
}