diff options
author | Jakob Borg <jakob@kastelo.net> | 2018-06-13 23:43:16 +0200 |
---|---|---|
committer | Jakob Borg <jakob@kastelo.net> | 2018-06-13 23:48:50 +0200 |
commit | 793b86e6040299778c245c525d7f4720a6998d0f (patch) | |
tree | 5c1bd2645880b648f4487469f239792bd265143a /script | |
parent | 7b47692ec0daa1802d265fa1dd408a45a3a5872c (diff) | |
download | syncthing-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.go | 6 |
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()), }) } |