Browse Source

Use more compact base64 encoding for assets

Jakob Borg 11 years ago
parent
commit
2e77e498f5
2 changed files with 9 additions and 9 deletions
  1. 2 2
      auto/gui.files.go
  2. 7 7
      cmd/genassets/main.go

File diff suppressed because it is too large
+ 2 - 2
auto/gui.files.go


+ 7 - 7
cmd/genassets/main.go

@@ -9,8 +9,8 @@ package main
 import (
 	"bytes"
 	"compress/gzip"
+	"encoding/base64"
 	"flag"
-	"fmt"
 	"go/format"
 	"io"
 	"os"
@@ -23,7 +23,7 @@ var tpl = template.Must(template.New("assets").Parse(`package auto
 import (
 	"bytes"
 	"compress/gzip"
-	"encoding/hex"
+	"encoding/base64"
 	"io/ioutil"
 )
 
@@ -33,7 +33,7 @@ func init() {
 	var bs []byte
 	var gr *gzip.Reader
 {{range $asset := .assets}}
-	bs, _ = hex.DecodeString("{{$asset.HexData}}")
+	bs, _ = base64.StdEncoding.DecodeString("{{$asset.Data}}")
 	gr, _ = gzip.NewReader(bytes.NewBuffer(bs))
 	bs, _ = ioutil.ReadAll(gr)
 	Assets["{{$asset.Name}}"] = bs
@@ -42,8 +42,8 @@ func init() {
 `))
 
 type asset struct {
-	Name    string
-	HexData string
+	Name string
+	Data string
 }
 
 var assets []asset
@@ -69,8 +69,8 @@ func walkerFor(basePath string) filepath.WalkFunc {
 
 			name, _ = filepath.Rel(basePath, name)
 			assets = append(assets, asset{
-				Name:    filepath.ToSlash(name),
-				HexData: fmt.Sprintf("%x", buf.Bytes()),
+				Name: filepath.ToSlash(name),
+				Data: base64.StdEncoding.EncodeToString(buf.Bytes()),
 			})
 		}
 

Some files were not shown because too many files changed in this diff