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/proto/text_parser.go b/proto/text_parser.go
index 714c803..358764b 100644
--- a/proto/text_parser.go
+++ b/proto/text_parser.go
@@ -36,19 +36,18 @@
import (
"fmt"
- "os"
"reflect"
"strconv"
)
-// ParseError satisfies the os.Error interface.
+// ParseError satisfies the error interface.
type ParseError struct {
Message string
Line int // 1-based line number
Offset int // 0-based byte offset from start of input
}
-func (p *ParseError) String() string {
+func (p *ParseError) Error() string {
if p.Line == 1 {
// show offset only for first line
return fmt.Sprintf("line 1.%d: %v", p.Offset, p.Message)
@@ -443,10 +442,10 @@
return p.errorf("invalid %v: %v", v.Type(), tok.value)
}
-var notPtrStruct os.Error = &ParseError{"destination is not a pointer to a struct", 0, 0}
+var notPtrStruct error = &ParseError{"destination is not a pointer to a struct", 0, 0}
// UnmarshalText reads a protobuffer in Text format.
-func UnmarshalText(s string, pb interface{}) os.Error {
+func UnmarshalText(s string, pb interface{}) error {
v := reflect.ValueOf(pb)
if v.Kind() != reflect.Ptr || v.Elem().Kind() != reflect.Struct {
return notPtrStruct