diff --git a/lib/bytewriter.go b/lib/bytewriter.go index c9b602c..05d6d67 100644 --- a/lib/bytewriter.go +++ b/lib/bytewriter.go @@ -9,7 +9,11 @@ import ( "io" ) -var newline = []byte{'\n'} +var ( + newline = []byte{'\n'} + dataindent = []byte{'\t', '\t'} + space = []byte{' '} +) type ByteWriter struct { io.Writer @@ -24,7 +28,10 @@ func (w *ByteWriter) Write(p []byte) (n int, err error) { for n = range p { if w.c%12 == 0 { w.Writer.Write(newline) + w.Writer.Write(dataindent) w.c = 0 + } else { + w.Writer.Write(space) } fmt.Fprintf(w.Writer, "0x%02x,", p[n]) diff --git a/lib/toc.go b/lib/toc.go index a534d93..4eb7350 100644 --- a/lib/toc.go +++ b/lib/toc.go @@ -21,7 +21,8 @@ func CreateTOC(dir, pkgname string) error { // After startup of the program, all generated data files will // put themselves in this map. The key is the full filename, as // supplied to go-bindata. -var go_bindata = make(map[string]func() []byte)`, pkgname) +var go_bindata = make(map[string]func() []byte) +`, pkgname) return ioutil.WriteFile(file, []byte(code), 0600) } @@ -31,7 +32,6 @@ var go_bindata = make(map[string]func() []byte)`, pkgname) func WriteTOCInit(output io.Writer, filename, prefix, funcname string) { filename = strings.Replace(filename, prefix, "", 1) fmt.Fprintf(output, ` - func init() { go_bindata[%q] = %s } diff --git a/lib/translate.go b/lib/translate.go index 4e8cb2f..224e00f 100644 --- a/lib/translate.go +++ b/lib/translate.go @@ -62,7 +62,8 @@ func %s() []byte { gz.Close() return b.Bytes() -}`) +} +`) } // input -> gzip -> gowriter -> output. @@ -77,7 +78,8 @@ func %s() []byte { fmt.Fprint(output, ` } -}`) +} +`) } // input -> gzip -> gowriter -> output. diff --git a/main.go b/main.go index 8682966..bce5d01 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,7 @@ import ( "os" "path" "path/filepath" + "strings" "unicode" ) @@ -90,7 +91,14 @@ func parseArgs() { pipe = flag.NArg() == 0 if !pipe { + sepsuffix := false + if strings.HasSuffix(*prefix, string(filepath.Separator)) { + sepsuffix = true + } *prefix, _ = filepath.Abs(filepath.Clean(*prefix)) + if sepsuffix { + *prefix += string(filepath.Separator) + } in, _ = filepath.Abs(filepath.Clean(flag.Args()[0])) *out = safeFilename(*out, in) }