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
// 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

View File

@ -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
}

View File

@ -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)

View File

@ -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,