goprotobuf: update to new errors.
Mostly gofix, but a few needed hand-work,
such as in the generator.

R=r, bradfitz, rsc
CC=golang-dev
http://codereview.appspot.com/5335045
diff --git a/compiler/descriptor/descriptor.pb.go b/compiler/descriptor/descriptor.pb.go
index 507126e..b5b402c 100644
--- a/compiler/descriptor/descriptor.pb.go
+++ b/compiler/descriptor/descriptor.pb.go
@@ -5,12 +5,10 @@
 
 import proto "goprotobuf.googlecode.com/hg/proto"
 import "math"
-import "os"
 
 // Reference proto, math & os imports to suppress error if they are not otherwise used.
 var _ = proto.GetString
 var _ = math.Inf
-var _ os.Error
 
 
 type FieldDescriptorProto_Type int32
diff --git a/compiler/generator/generator.go b/compiler/generator/generator.go
index ca1e576..095bfc3 100644
--- a/compiler/generator/generator.go
+++ b/compiler/generator/generator.go
@@ -274,9 +274,9 @@
 		g.P("func (this *", ms.sym, ") ExtensionMap() map[int32]", g.ProtoPkg, ".Extension ",
 			"{ return (*", remoteSym, ")(this).ExtensionMap() }")
 		if ms.isMessageSet {
-			g.P("func (this *", ms.sym, ") Marshal() ([]byte, os.Error) ",
+			g.P("func (this *", ms.sym, ") Marshal() ([]byte, error) ",
 				"{ return (*", remoteSym, ")(this).Marshal() }")
-			g.P("func (this *", ms.sym, ") Unmarshal(buf []byte) os.Error ",
+			g.P("func (this *", ms.sym, ") Unmarshal(buf []byte) error ",
 				"{ return (*", remoteSym, ")(this).Unmarshal(buf) }")
 		}
 	}
@@ -351,9 +351,9 @@
 	return g
 }
 
-// Error reports a problem, including an os.Error, and exits the program.
-func (g *Generator) Error(err os.Error, msgs ...string) {
-	s := strings.Join(msgs, " ") + ":" + err.String()
+// Error reports a problem, including an error, and exits the program.
+func (g *Generator) Error(err error, msgs ...string) {
+	s := strings.Join(msgs, " ") + ":" + err.Error()
 	log.Println("protoc-gen-go: error:", s)
 	g.Response.Error = proto.String(s)
 	os.Exit(1)
@@ -780,13 +780,13 @@
 	fset := token.NewFileSet()
 	ast, err := parser.ParseFile(fset, "", g, parser.ParseComments)
 	if err != nil {
-		g.Fail("bad Go source code was generated:", err.String())
+		g.Fail("bad Go source code was generated:", err.Error())
 		return
 	}
 	g.Reset()
 	_, err = (&printer.Config{printer.TabIndent | printer.UseSpaces, 8}).Fprint(g, fset, ast)
 	if err != nil {
-		g.Fail("generated Go source code could not be reformatted:", err.String())
+		g.Fail("generated Go source code could not be reformatted:", err.Error())
 	}
 }
 
@@ -812,10 +812,10 @@
 func (g *Generator) generateImports() {
 	// We almost always need a proto import.  Rather than computing when we
 	// do, which is tricky when there's a plugin, just import it and
-	// reference it later. The same argument applies to the os package.
+	// reference it later. The same argument applies to the math package,
+	// for handling bit patterns for floating-point numbers.
 	g.P("import " + g.ProtoPkg + " " + Quote(g.ImportPrefix+"goprotobuf.googlecode.com/hg/proto"))
 	g.P(`import "math"`)
-	g.P(`import "os"`)
 	for _, s := range g.file.Dependency {
 		fd := g.fileByName(s)
 		// Do not import our own package.
@@ -846,10 +846,9 @@
 		p.GenerateImports(g.file)
 		g.P()
 	}
-	g.P("// Reference proto, math & os imports to suppress error if they are not otherwise used.")
+	g.P("// Reference proto & math imports to suppress error if they are not otherwise used.")
 	g.P("var _ = ", g.ProtoPkg, ".GetString")
 	g.P("var _ = math.Inf")
-	g.P("var _ os.Error")
 	g.P()
 }
 
@@ -1147,12 +1146,12 @@
 		if opts := message.Options; opts != nil && proto.GetBool(opts.MessageSetWireFormat) {
 			isMessageSet = true
 			g.P()
-			g.P("func (this *", ccTypeName, ") Marshal() ([]byte, os.Error) {")
+			g.P("func (this *", ccTypeName, ") Marshal() ([]byte, error) {")
 			g.In()
 			g.P("return ", g.ProtoPkg, ".MarshalMessageSet(this.ExtensionMap())")
 			g.Out()
 			g.P("}")
-			g.P("func (this *", ccTypeName, ") Unmarshal(buf []byte) os.Error {")
+			g.P("func (this *", ccTypeName, ") Unmarshal(buf []byte) error {")
 			g.In()
 			g.P("return ", g.ProtoPkg, ".UnmarshalMessageSet(buf, this.ExtensionMap())")
 			g.Out()
diff --git a/compiler/plugin/plugin.pb.go b/compiler/plugin/plugin.pb.go
index ac80dc4..f85b5c6 100644
--- a/compiler/plugin/plugin.pb.go
+++ b/compiler/plugin/plugin.pb.go
@@ -5,43 +5,42 @@
 
 import proto "goprotobuf.googlecode.com/hg/proto"
 import "math"
-import "os"
+
 import google_protobuf "goprotobuf.googlecode.com/hg/compiler/descriptor"
 
 // Reference proto, math & os imports to suppress error if they are not otherwise used.
 var _ = proto.GetString
 var _ = math.Inf
-var _ os.Error
-
+var _ error
 
 type CodeGeneratorRequest struct {
-	FileToGenerate		[]string				`protobuf:"bytes,1,rep,name=file_to_generate"`
-	Parameter		*string					`protobuf:"bytes,2,opt,name=parameter"`
-	ProtoFile		[]*google_protobuf.FileDescriptorProto	`protobuf:"bytes,15,rep,name=proto_file"`
-	XXX_unrecognized	[]byte
+	FileToGenerate   []string                               `protobuf:"bytes,1,rep,name=file_to_generate"`
+	Parameter        *string                                `protobuf:"bytes,2,opt,name=parameter"`
+	ProtoFile        []*google_protobuf.FileDescriptorProto `protobuf:"bytes,15,rep,name=proto_file"`
+	XXX_unrecognized []byte
 }
 
-func (this *CodeGeneratorRequest) Reset()		{ *this = CodeGeneratorRequest{} }
-func (this *CodeGeneratorRequest) String() string	{ return proto.CompactTextString(this) }
+func (this *CodeGeneratorRequest) Reset()         { *this = CodeGeneratorRequest{} }
+func (this *CodeGeneratorRequest) String() string { return proto.CompactTextString(this) }
 
 type CodeGeneratorResponse struct {
-	Error			*string				`protobuf:"bytes,1,opt,name=error"`
-	File			[]*CodeGeneratorResponse_File	`protobuf:"bytes,15,rep,name=file"`
-	XXX_unrecognized	[]byte
+	Error            *string                       `protobuf:"bytes,1,opt,name=error"`
+	File             []*CodeGeneratorResponse_File `protobuf:"bytes,15,rep,name=file"`
+	XXX_unrecognized []byte
 }
 
-func (this *CodeGeneratorResponse) Reset()		{ *this = CodeGeneratorResponse{} }
-func (this *CodeGeneratorResponse) String() string	{ return proto.CompactTextString(this) }
+func (this *CodeGeneratorResponse) Reset()         { *this = CodeGeneratorResponse{} }
+func (this *CodeGeneratorResponse) String() string { return proto.CompactTextString(this) }
 
 type CodeGeneratorResponse_File struct {
-	Name			*string	`protobuf:"bytes,1,opt,name=name"`
-	InsertionPoint		*string	`protobuf:"bytes,2,opt,name=insertion_point"`
-	Content			*string	`protobuf:"bytes,15,opt,name=content"`
-	XXX_unrecognized	[]byte
+	Name             *string `protobuf:"bytes,1,opt,name=name"`
+	InsertionPoint   *string `protobuf:"bytes,2,opt,name=insertion_point"`
+	Content          *string `protobuf:"bytes,15,opt,name=content"`
+	XXX_unrecognized []byte
 }
 
-func (this *CodeGeneratorResponse_File) Reset()		{ *this = CodeGeneratorResponse_File{} }
-func (this *CodeGeneratorResponse_File) String() string	{ return proto.CompactTextString(this) }
+func (this *CodeGeneratorResponse_File) Reset()         { *this = CodeGeneratorResponse_File{} }
+func (this *CodeGeneratorResponse_File) String() string { return proto.CompactTextString(this) }
 
 func init() {
 }
diff --git a/compiler/testdata/imp.pb.go.golden b/compiler/testdata/imp.pb.go.golden
index c038c74..bd6b59b 100644
--- a/compiler/testdata/imp.pb.go.golden
+++ b/compiler/testdata/imp.pb.go.golden
@@ -8,10 +8,9 @@
 import "os"
 import imp1 "imp2.pb"
 
-// Reference proto, math & os imports to suppress error if they are not otherwise used.
+// Reference proto & math imports to suppress error if they are not otherwise used.
 var _ = proto.GetString
 var _ = math.Inf
-var _ os.Error
 
 // Types from public import imp2.proto
 type PubliclyImportedMessage imp1.PubliclyImportedMessage
@@ -78,10 +77,10 @@
 func (this *ImportedExtendable) Reset()         { *this = ImportedExtendable{} }
 func (this *ImportedExtendable) String() string { return proto.CompactTextString(this) }
 
-func (this *ImportedExtendable) Marshal() ([]byte, os.Error) {
+func (this *ImportedExtendable) Marshal() ([]byte, error) {
 	return proto.MarshalMessageSet(this.ExtensionMap())
 }
-func (this *ImportedExtendable) Unmarshal(buf []byte) os.Error {
+func (this *ImportedExtendable) Unmarshal(buf []byte) error {
 	return proto.UnmarshalMessageSet(buf, this.ExtensionMap())
 }
 // ensure ImportedExtendable satisfies proto.Marshaler and proto.Unmarshaler
diff --git a/compiler/testdata/test.pb.go.golden b/compiler/testdata/test.pb.go.golden
index 233d1f9..631cd5d 100644
--- a/compiler/testdata/test.pb.go.golden
+++ b/compiler/testdata/test.pb.go.golden
@@ -5,14 +5,12 @@
 
 import proto "goprotobuf.googlecode.com/hg/proto"
 import "math"
-import "os"
 import imp1 "imp.pb"
 // discarding unused import multitest2 "multi1.pb"
 
-// Reference proto, math & os imports to suppress error if they are not otherwise used.
+// Reference proto & math imports to suppress error if they are not otherwise used.
 var _ = proto.GetString
 var _ = math.Inf
-var _ os.Error
 
 type HatType int32
 
@@ -201,10 +199,10 @@
 func (this *OldReply) Reset()         { *this = OldReply{} }
 func (this *OldReply) String() string { return proto.CompactTextString(this) }
 
-func (this *OldReply) Marshal() ([]byte, os.Error) {
+func (this *OldReply) Marshal() ([]byte, error) {
 	return proto.MarshalMessageSet(this.ExtensionMap())
 }
-func (this *OldReply) Unmarshal(buf []byte) os.Error {
+func (this *OldReply) Unmarshal(buf []byte) error {
 	return proto.UnmarshalMessageSet(buf, this.ExtensionMap())
 }
 // ensure OldReply satisfies proto.Marshaler and proto.Unmarshaler