Merge pull request #15 from pblaszczyk/fix
Fix for handling prefix value and output not formatted according to go fmt.
This commit is contained in:
commit
37aa0dc02e
|
@ -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])
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
8
main.go
8
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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user