Some more code cleanup.

pull/4/head
jim teeuwen 2012-06-07 23:34:34 +02:00
parent 665944b444
commit ed2cd8b81c
2 changed files with 18 additions and 16 deletions

View File

@ -9,6 +9,8 @@ import (
"io" "io"
) )
var newline = []byte{'\n'}
type GoWriter struct { type GoWriter struct {
io.Writer io.Writer
c int c int
@ -21,7 +23,7 @@ func (w *GoWriter) Write(p []byte) (n int, err error) {
for n = range p { for n = range p {
if w.c%12 == 0 { if w.c%12 == 0 {
w.Writer.Write([]byte{'\n'}) w.Writer.Write(newline)
w.c = 0 w.c = 0
} }

View File

@ -74,8 +74,9 @@ func main() {
if pipe { if pipe {
// Can't infer from input file name in this mode. // Can't infer from input file name in this mode.
fmt.Fprintln(os.Stderr, "[e] No function name specified.") fmt.Fprintln(os.Stderr, "[e] No function name specified.")
os.Exit(1) return
} else { }
_, file := path.Split(*in) _, file := path.Split(*in)
file = strings.ToLower(file) file = strings.ToLower(file)
file = strings.Replace(file, " ", "_", -1) file = strings.Replace(file, " ", "_", -1)
@ -90,7 +91,6 @@ func main() {
fmt.Fprintf(os.Stderr, "[w] No function name specified. Using '%s'.\n", file) fmt.Fprintf(os.Stderr, "[w] No function name specified. Using '%s'.\n", file)
*funcname = file *funcname = file
} }
}
// Read the input file, transform it into a gzip compressed data stream and // Read the input file, transform it into a gzip compressed data stream and
// write it out as a go source file. // write it out as a go source file.