Some more code cleanup.
This commit is contained in:
parent
665944b444
commit
ed2cd8b81c
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
main.go
6
main.go
|
@ -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.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user