gofix error

This commit is contained in:
jim teeuwen 2011-11-02 16:40:26 +01:00
parent 5b255b58ee
commit efcb2b8d06
4 changed files with 8 additions and 10 deletions

View File

@ -15,7 +15,7 @@ import (
// If gofmt exists on the system, run it over the target file to // 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. // 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 var prog string
if prog = os.Getenv("GOBIN"); len(prog) == 0 { if prog = os.Getenv("GOBIN"); len(prog) == 0 {
return return
@ -28,7 +28,7 @@ func gofmt(file string) (err os.Error) {
// Translate the input file. // Translate the input file.
// input -> gzip -> gowriter -> output. // 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 var gz *gzip.Compressor
fmt.Fprintf(output, `package %s fmt.Fprintf(output, `package %s

View File

@ -7,7 +7,6 @@ package main
import ( import (
"fmt" "fmt"
"io" "io"
"os"
) )
type GoWriter struct { type GoWriter struct {
@ -15,7 +14,7 @@ type GoWriter struct {
c int 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 { if len(p) == 0 {
return return
} }

View File

@ -91,7 +91,7 @@ func main() {
// 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.
var err os.Error var err error
if pipe { if pipe {
if err = translate(os.Stdin, os.Stdout, *pkgname, *funcname); err != nil { if err = translate(os.Stdin, os.Stdout, *pkgname, *funcname); err != nil {
fmt.Fprintf(os.Stderr, "[e] %s\n", err) fmt.Fprintf(os.Stderr, "[e] %s\n", err)
@ -104,14 +104,14 @@ func main() {
fmt.Fprintf(os.Stderr, "[e] %s\n", err) fmt.Fprintf(os.Stderr, "[e] %s\n", err)
return return
} }
defer fs.Close() defer fs.Close()
if fd, err = os.Create(*out); err != nil { if fd, err = os.Create(*out); err != nil {
fmt.Fprintf(os.Stderr, "[e] %s\n", err) fmt.Fprintf(os.Stderr, "[e] %s\n", err)
return return
} }
defer fd.Close() defer fd.Close()
if err = translate(fs, fd, *pkgname, *funcname); err != nil { if err = translate(fs, fd, *pkgname, *funcname); err != nil {

View File

@ -2,14 +2,13 @@ package main
import ( import (
"io" "io"
"os"
"bytes" "bytes"
"compress/gzip" "compress/gzip"
) )
func gophercolor_png() ([]byte, os.Error) { func gophercolor_png() ([]byte, error) {
var gz *gzip.Decompressor var gz *gzip.Decompressor
var err os.Error var err error
if gz, err = gzip.NewReader(bytes.NewBuffer([]byte{ if gz, err = gzip.NewReader(bytes.NewBuffer([]byte{
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x34, 0x9b, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x34, 0x9b,
0x65, 0x50, 0x1b, 0x5f, 0x17, 0xc6, 0x43, 0x69, 0x8b, 0xbb, 0xbb, 0xbb, 0x65, 0x50, 0x1b, 0x5f, 0x17, 0xc6, 0x43, 0x69, 0x8b, 0xbb, 0xbb, 0xbb,