aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/json/decode.go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-12-03 02:17:34 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-12-03 02:17:34 +0000
commit2fd401c8f190f1fe43e51a7f726f6ed6119a1f96 (patch)
tree7f76eff391f37fe6467ff4ffbc0c582c9959ea30 /libgo/go/json/decode.go
parent02e9018f1616b23f1276151797216717b3564202 (diff)
downloadgcc-2fd401c8f190f1fe43e51a7f726f6ed6119a1f96.zip
gcc-2fd401c8f190f1fe43e51a7f726f6ed6119a1f96.tar.gz
gcc-2fd401c8f190f1fe43e51a7f726f6ed6119a1f96.tar.bz2
libgo: Update to weekly.2011-11-02.
From-SVN: r181964
Diffstat (limited to 'libgo/go/json/decode.go')
-rw-r--r--libgo/go/json/decode.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/libgo/go/json/decode.go b/libgo/go/json/decode.go
index 800df98..8abd7b4 100644
--- a/libgo/go/json/decode.go
+++ b/libgo/go/json/decode.go
@@ -9,7 +9,7 @@ package json
import (
"encoding/base64"
- "os"
+ "errors"
"reflect"
"runtime"
"strconv"
@@ -50,7 +50,7 @@ import (
// If no more serious errors are encountered, Unmarshal returns
// an UnmarshalTypeError describing the earliest such error.
//
-func Unmarshal(data []byte, v interface{}) os.Error {
+func Unmarshal(data []byte, v interface{}) error {
d := new(decodeState).init(data)
// Quick check for well-formedness.
@@ -70,7 +70,7 @@ func Unmarshal(data []byte, v interface{}) os.Error {
// encoding. UnmarshalJSON must copy the JSON data
// if it wishes to retain the data after returning.
type Unmarshaler interface {
- UnmarshalJSON([]byte) os.Error
+ UnmarshalJSON([]byte) error
}
// An UnmarshalTypeError describes a JSON value that was
@@ -80,7 +80,7 @@ type UnmarshalTypeError struct {
Type reflect.Type // type of Go value it could not be assigned to
}
-func (e *UnmarshalTypeError) String() string {
+func (e *UnmarshalTypeError) Error() string {
return "json: cannot unmarshal " + e.Value + " into Go value of type " + e.Type.String()
}
@@ -92,7 +92,7 @@ type UnmarshalFieldError struct {
Field reflect.StructField
}
-func (e *UnmarshalFieldError) String() string {
+func (e *UnmarshalFieldError) Error() string {
return "json: cannot unmarshal object key " + strconv.Quote(e.Key) + " into unexported field " + e.Field.Name + " of type " + e.Type.String()
}
@@ -102,7 +102,7 @@ type InvalidUnmarshalError struct {
Type reflect.Type
}
-func (e *InvalidUnmarshalError) String() string {
+func (e *InvalidUnmarshalError) Error() string {
if e.Type == nil {
return "json: Unmarshal(nil)"
}
@@ -113,13 +113,13 @@ func (e *InvalidUnmarshalError) String() string {
return "json: Unmarshal(nil " + e.Type.String() + ")"
}
-func (d *decodeState) unmarshal(v interface{}) (err os.Error) {
+func (d *decodeState) unmarshal(v interface{}) (err error) {
defer func() {
if r := recover(); r != nil {
if _, ok := r.(runtime.Error); ok {
panic(r)
}
- err = r.(os.Error)
+ err = r.(error)
}
}()
@@ -142,14 +142,14 @@ type decodeState struct {
off int // read offset in data
scan scanner
nextscan scanner // for calls to nextValue
- savedError os.Error
+ savedError error
tempstr string // scratch space to avoid some allocations
}
// errPhase is used for errors that should not happen unless
// there is a bug in the JSON decoder or something is editing
// the data slice while the decoder executes.
-var errPhase = os.NewError("JSON decoder out of sync - data changing underfoot?")
+var errPhase = errors.New("JSON decoder out of sync - data changing underfoot?")
func (d *decodeState) init(data []byte) *decodeState {
d.data = data
@@ -159,13 +159,13 @@ func (d *decodeState) init(data []byte) *decodeState {
}
// error aborts the decoding by panicking with err.
-func (d *decodeState) error(err os.Error) {
+func (d *decodeState) error(err error) {
panic(err)
}
// saveError saves the first err it is called with,
// for reporting at the end of the unmarshal.
-func (d *decodeState) saveError(err os.Error) {
+func (d *decodeState) saveError(err error) {
if d.savedError == nil {
d.savedError = err
}