gofix error
This commit is contained in:
parent
5b255b58ee
commit
efcb2b8d06
|
@ -15,7 +15,7 @@ import (
|
|||
|
||||
// If gofmt exists on the system, run it over the target file to
|
||||
// fix up the generated code. This is not necessary, just a convenience.
|
||||
func gofmt(file string) (err os.Error) {
|
||||
func gofmt(file string) (err error) {
|
||||
var prog string
|
||||
if prog = os.Getenv("GOBIN"); len(prog) == 0 {
|
||||
return
|
||||
|
@ -28,7 +28,7 @@ func gofmt(file string) (err os.Error) {
|
|||
|
||||
// Translate the input file.
|
||||
// input -> gzip -> gowriter -> output.
|
||||
func translate(input io.Reader, output io.Writer, pkgname, funcname string) (err os.Error) {
|
||||
func translate(input io.Reader, output io.Writer, pkgname, funcname string) (err error) {
|
||||
var gz *gzip.Compressor
|
||||
|
||||
fmt.Fprintf(output, `package %s
|
||||
|
|
|
@ -7,7 +7,6 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
type GoWriter struct {
|
||||
|
@ -15,7 +14,7 @@ type GoWriter struct {
|
|||
c int
|
||||
}
|
||||
|
||||
func (this *GoWriter) Write(p []byte) (n int, err os.Error) {
|
||||
func (this *GoWriter) Write(p []byte) (n int, err error) {
|
||||
if len(p) == 0 {
|
||||
return
|
||||
}
|
||||
|
|
6
main.go
6
main.go
|
@ -91,7 +91,7 @@ func main() {
|
|||
|
||||
// Read the input file, transform it into a gzip compressed data stream and
|
||||
// write it out as a go source file.
|
||||
var err os.Error
|
||||
var err error
|
||||
if pipe {
|
||||
if err = translate(os.Stdin, os.Stdout, *pkgname, *funcname); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "[e] %s\n", err)
|
||||
|
@ -104,14 +104,14 @@ func main() {
|
|||
fmt.Fprintf(os.Stderr, "[e] %s\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
defer fs.Close()
|
||||
|
||||
if fd, err = os.Create(*out); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "[e] %s\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
defer fd.Close()
|
||||
|
||||
if err = translate(fs, fd, *pkgname, *funcname); err != nil {
|
||||
|
|
5
testdata/gophercolor.png.go
vendored
5
testdata/gophercolor.png.go
vendored
|
@ -2,14 +2,13 @@ package main
|
|||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
)
|
||||
|
||||
func gophercolor_png() ([]byte, os.Error) {
|
||||
func gophercolor_png() ([]byte, error) {
|
||||
var gz *gzip.Decompressor
|
||||
var err os.Error
|
||||
var err error
|
||||
if gz, err = gzip.NewReader(bytes.NewBuffer([]byte{
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x34, 0x9b,
|
||||
0x65, 0x50, 0x1b, 0x5f, 0x17, 0xc6, 0x43, 0x69, 0x8b, 0xbb, 0xbb, 0xbb,
|
||||
|
|
Loading…
Reference in New Issue
Block a user