src/pkg/[a-m]*: gofix -r error -force=error

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/5322051
diff --git a/src/pkg/gob/codec_test.go b/src/pkg/gob/codec_test.go
index 5306354..dc0e007 100644
--- a/src/pkg/gob/codec_test.go
+++ b/src/pkg/gob/codec_test.go
@@ -6,8 +6,8 @@
 
 import (
 	"bytes"
+	"errors"
 	"math"
-	"os"
 	"reflect"
 	"strings"
 	"testing"
@@ -330,7 +330,7 @@
 // Test instruction execution for decoding.
 // Do not run the machine yet; instead do individual instructions crafted by hand.
 func TestScalarDecInstructions(t *testing.T) {
-	ovfl := os.NewError("overflow")
+	ovfl := errors.New("overflow")
 
 	// bool
 	{
@@ -633,7 +633,7 @@
 		Minc complex128
 	}
 	var it inputT
-	var err os.Error
+	var err error
 	b := new(bytes.Buffer)
 	enc := NewEncoder(b)
 	dec := NewDecoder(b)
@@ -650,7 +650,7 @@
 	var o1 outi8
 	enc.Encode(it)
 	err = dec.Decode(&o1)
-	if err == nil || err.String() != `value for "Maxi" out of range` {
+	if err == nil || err.Error() != `value for "Maxi" out of range` {
 		t.Error("wrong overflow error for int8:", err)
 	}
 	it = inputT{
@@ -659,7 +659,7 @@
 	b.Reset()
 	enc.Encode(it)
 	err = dec.Decode(&o1)
-	if err == nil || err.String() != `value for "Mini" out of range` {
+	if err == nil || err.Error() != `value for "Mini" out of range` {
 		t.Error("wrong underflow error for int8:", err)
 	}
 
@@ -675,7 +675,7 @@
 	var o2 outi16
 	enc.Encode(it)
 	err = dec.Decode(&o2)
-	if err == nil || err.String() != `value for "Maxi" out of range` {
+	if err == nil || err.Error() != `value for "Maxi" out of range` {
 		t.Error("wrong overflow error for int16:", err)
 	}
 	it = inputT{
@@ -684,7 +684,7 @@
 	b.Reset()
 	enc.Encode(it)
 	err = dec.Decode(&o2)
-	if err == nil || err.String() != `value for "Mini" out of range` {
+	if err == nil || err.Error() != `value for "Mini" out of range` {
 		t.Error("wrong underflow error for int16:", err)
 	}
 
@@ -700,7 +700,7 @@
 	var o3 outi32
 	enc.Encode(it)
 	err = dec.Decode(&o3)
-	if err == nil || err.String() != `value for "Maxi" out of range` {
+	if err == nil || err.Error() != `value for "Maxi" out of range` {
 		t.Error("wrong overflow error for int32:", err)
 	}
 	it = inputT{
@@ -709,7 +709,7 @@
 	b.Reset()
 	enc.Encode(it)
 	err = dec.Decode(&o3)
-	if err == nil || err.String() != `value for "Mini" out of range` {
+	if err == nil || err.Error() != `value for "Mini" out of range` {
 		t.Error("wrong underflow error for int32:", err)
 	}
 
@@ -724,7 +724,7 @@
 	var o4 outu8
 	enc.Encode(it)
 	err = dec.Decode(&o4)
-	if err == nil || err.String() != `value for "Maxu" out of range` {
+	if err == nil || err.Error() != `value for "Maxu" out of range` {
 		t.Error("wrong overflow error for uint8:", err)
 	}
 
@@ -739,7 +739,7 @@
 	var o5 outu16
 	enc.Encode(it)
 	err = dec.Decode(&o5)
-	if err == nil || err.String() != `value for "Maxu" out of range` {
+	if err == nil || err.Error() != `value for "Maxu" out of range` {
 		t.Error("wrong overflow error for uint16:", err)
 	}
 
@@ -754,7 +754,7 @@
 	var o6 outu32
 	enc.Encode(it)
 	err = dec.Decode(&o6)
-	if err == nil || err.String() != `value for "Maxu" out of range` {
+	if err == nil || err.Error() != `value for "Maxu" out of range` {
 		t.Error("wrong overflow error for uint32:", err)
 	}
 
@@ -770,7 +770,7 @@
 	var o7 outf32
 	enc.Encode(it)
 	err = dec.Decode(&o7)
-	if err == nil || err.String() != `value for "Maxf" out of range` {
+	if err == nil || err.Error() != `value for "Maxf" out of range` {
 		t.Error("wrong overflow error for float32:", err)
 	}
 
@@ -786,7 +786,7 @@
 	var o8 outc64
 	enc.Encode(it)
 	err = dec.Decode(&o8)
-	if err == nil || err.String() != `value for "Maxc" out of range` {
+	if err == nil || err.Error() != `value for "Maxc" out of range` {
 		t.Error("wrong overflow error for complex64:", err)
 	}
 }
@@ -995,7 +995,7 @@
 	err := NewEncoder(b).Encode(&rec)
 	if err == nil {
 		t.Error("expected error; got none")
-	} else if strings.Index(err.String(), "recursive") < 0 {
+	} else if strings.Index(err.Error(), "recursive") < 0 {
 		t.Error("expected recursive type error; got", err)
 	}
 	// Can't test decode easily because we can't encode one, so we can't pass one to a Decoder.
@@ -1014,7 +1014,7 @@
 	dummyEncoder.encode(b, reflect.ValueOf(&bad0), userType(reflect.TypeOf(&bad0)))
 	if err := dummyEncoder.err; err == nil {
 		t.Error("expected error; got none")
-	} else if strings.Index(err.String(), "type") < 0 {
+	} else if strings.Index(err.Error(), "type") < 0 {
 		t.Error("expected type error; got", err)
 	}
 }
diff --git a/src/pkg/gob/debug.go b/src/pkg/gob/debug.go
index 16c2194..b21c7fa 100644
--- a/src/pkg/gob/debug.go
+++ b/src/pkg/gob/debug.go
@@ -56,7 +56,7 @@
 }
 
 // Read is the usual method. It will first take data that has been read ahead.
-func (p *peekReader) Read(b []byte) (n int, err os.Error) {
+func (p *peekReader) Read(b []byte) (n int, err error) {
 	if len(p.data) == 0 {
 		return p.r.Read(b)
 	}
@@ -70,7 +70,7 @@
 
 // peek returns as many bytes as possible from the unread
 // portion of the stream, up to the length of b.
-func (p *peekReader) peek(b []byte) (n int, err os.Error) {
+func (p *peekReader) peek(b []byte) (n int, err error) {
 	if len(p.data) > 0 {
 		n = copy(b, p.data)
 		if n == len(b) {
@@ -92,7 +92,7 @@
 		if n > 0 {
 			e = nil
 		} else {
-			e = os.EOF
+			e = io.EOF
 		}
 	}
 	return n, e
@@ -164,7 +164,7 @@
 
 // debug implements Debug, but catches panics and returns
 // them as errors to be printed by Debug.
-func debug(r io.Reader) (err os.Error) {
+func debug(r io.Reader) (err error) {
 	defer catchError(&err)
 	fmt.Fprintln(os.Stderr, "Start of debugging")
 	deb := &debugger{
@@ -238,7 +238,7 @@
 func (deb *debugger) loadBlock(eofOK bool) int {
 	n64, w, err := decodeUintReader(deb.r, deb.tmp) // deb.uint64 will error at EOF
 	if err != nil {
-		if eofOK && err == os.EOF {
+		if eofOK && err == io.EOF {
 			return -1
 		}
 		errorf("debug: unexpected error: %s", err)
diff --git a/src/pkg/gob/decode.go b/src/pkg/gob/decode.go
index d027d3f..1515d12 100644
--- a/src/pkg/gob/decode.go
+++ b/src/pkg/gob/decode.go
@@ -9,17 +9,17 @@
 
 import (
 	"bytes"
+	"errors"
 	"io"
 	"math"
-	"os"
 	"reflect"
 	"unsafe"
 )
 
 var (
-	errBadUint = os.NewError("gob: encoded unsigned integer out of range")
-	errBadType = os.NewError("gob: unknown type id or corrupted data")
-	errRange   = os.NewError("gob: bad data: field numbers out of bounds")
+	errBadUint = errors.New("gob: encoded unsigned integer out of range")
+	errBadType = errors.New("gob: unknown type id or corrupted data")
+	errRange   = errors.New("gob: bad data: field numbers out of bounds")
 )
 
 // decoderState is the execution state of an instance of the decoder. A new state
@@ -54,13 +54,13 @@
 	dec.freeList = d
 }
 
-func overflow(name string) os.Error {
-	return os.NewError(`value for "` + name + `" out of range`)
+func overflow(name string) error {
+	return errors.New(`value for "` + name + `" out of range`)
 }
 
 // decodeUintReader reads an encoded unsigned integer from an io.Reader.
 // Used only by the Decoder to read the message length.
-func decodeUintReader(r io.Reader, buf []byte) (x uint64, width int, err os.Error) {
+func decodeUintReader(r io.Reader, buf []byte) (x uint64, width int, err error) {
 	width = 1
 	_, err = r.Read(buf[0:width])
 	if err != nil {
@@ -77,7 +77,7 @@
 	}
 	width, err = io.ReadFull(r, buf[0:n])
 	if err != nil {
-		if err == os.EOF {
+		if err == io.EOF {
 			err = io.ErrUnexpectedEOF
 		}
 		return
@@ -95,18 +95,18 @@
 func (state *decoderState) decodeUint() (x uint64) {
 	b, err := state.b.ReadByte()
 	if err != nil {
-		error(err)
+		error_(err)
 	}
 	if b <= 0x7f {
 		return uint64(b)
 	}
 	n := -int(int8(b))
 	if n > uint64Size {
-		error(errBadUint)
+		error_(errBadUint)
 	}
 	width, err := state.b.Read(state.buf[0:n])
 	if err != nil {
-		error(err)
+		error_(err)
 	}
 	// Don't need to check error; it's safe to loop regardless.
 	// Could check that the high byte is zero but it's not worth it.
@@ -132,10 +132,10 @@
 // The 'instructions' of the decoding machine
 type decInstr struct {
 	op     decOp
-	field  int      // field number of the wire type
-	indir  int      // how many pointer indirections to reach the value in the struct
-	offset uintptr  // offset in the structure of the field to encode
-	ovfl   os.Error // error message for overflow/underflow (for arrays, of the elements)
+	field  int     // field number of the wire type
+	indir  int     // how many pointer indirections to reach the value in the struct
+	offset uintptr // offset in the structure of the field to encode
+	ovfl   error   // error message for overflow/underflow (for arrays, of the elements)
 }
 
 // Since the encoder writes no zeros, if we arrive at a decoder we have
@@ -190,7 +190,7 @@
 	}
 	v := state.decodeInt()
 	if v < math.MinInt8 || math.MaxInt8 < v {
-		error(i.ovfl)
+		error_(i.ovfl)
 	} else {
 		*(*int8)(p) = int8(v)
 	}
@@ -206,7 +206,7 @@
 	}
 	v := state.decodeUint()
 	if math.MaxUint8 < v {
-		error(i.ovfl)
+		error_(i.ovfl)
 	} else {
 		*(*uint8)(p) = uint8(v)
 	}
@@ -222,7 +222,7 @@
 	}
 	v := state.decodeInt()
 	if v < math.MinInt16 || math.MaxInt16 < v {
-		error(i.ovfl)
+		error_(i.ovfl)
 	} else {
 		*(*int16)(p) = int16(v)
 	}
@@ -238,7 +238,7 @@
 	}
 	v := state.decodeUint()
 	if math.MaxUint16 < v {
-		error(i.ovfl)
+		error_(i.ovfl)
 	} else {
 		*(*uint16)(p) = uint16(v)
 	}
@@ -254,7 +254,7 @@
 	}
 	v := state.decodeInt()
 	if v < math.MinInt32 || math.MaxInt32 < v {
-		error(i.ovfl)
+		error_(i.ovfl)
 	} else {
 		*(*int32)(p) = int32(v)
 	}
@@ -270,7 +270,7 @@
 	}
 	v := state.decodeUint()
 	if math.MaxUint32 < v {
-		error(i.ovfl)
+		error_(i.ovfl)
 	} else {
 		*(*uint32)(p) = uint32(v)
 	}
@@ -323,7 +323,7 @@
 	}
 	// +Inf is OK in both 32- and 64-bit floats.  Underflow is always OK.
 	if math.MaxFloat32 < av && av <= math.MaxFloat64 {
-		error(i.ovfl)
+		error_(i.ovfl)
 	} else {
 		*(*float32)(p) = float32(v)
 	}
@@ -464,7 +464,7 @@
 // decodeSingle decodes a top-level value that is not a struct and stores it through p.
 // Such values are preceded by a zero, making them have the memory layout of a
 // struct field (although with an illegal field number).
-func (dec *Decoder) decodeSingle(engine *decEngine, ut *userTypeInfo, basep uintptr) (err os.Error) {
+func (dec *Decoder) decodeSingle(engine *decEngine, ut *userTypeInfo, basep uintptr) (err error) {
 	state := dec.newDecoderState(&dec.buf)
 	state.fieldnum = singletonField
 	delta := int(state.decodeUint())
@@ -473,7 +473,7 @@
 	}
 	instr := &engine.instr[singletonField]
 	if instr.indir != ut.indir {
-		return os.NewError("gob: internal error: inconsistent indirection")
+		return errors.New("gob: internal error: inconsistent indirection")
 	}
 	ptr := unsafe.Pointer(basep) // offset will be zero
 	if instr.indir > 1 {
@@ -504,7 +504,7 @@
 		}
 		fieldnum := state.fieldnum + delta
 		if fieldnum >= len(engine.instr) {
-			error(errRange)
+			error_(errRange)
 			break
 		}
 		instr := &engine.instr[fieldnum]
@@ -532,7 +532,7 @@
 		}
 		fieldnum := state.fieldnum + delta
 		if fieldnum >= len(engine.instr) {
-			error(errRange)
+			error_(errRange)
 		}
 		instr := &engine.instr[fieldnum]
 		instr.op(instr, state, unsafe.Pointer(nil))
@@ -556,7 +556,7 @@
 }
 
 // decodeArrayHelper does the work for decoding arrays and slices.
-func (dec *Decoder) decodeArrayHelper(state *decoderState, p uintptr, elemOp decOp, elemWid uintptr, length, elemIndir int, ovfl os.Error) {
+func (dec *Decoder) decodeArrayHelper(state *decoderState, p uintptr, elemOp decOp, elemWid uintptr, length, elemIndir int, ovfl error) {
 	instr := &decInstr{elemOp, 0, elemIndir, 0, ovfl}
 	for i := 0; i < length; i++ {
 		up := unsafe.Pointer(p)
@@ -571,7 +571,7 @@
 // decodeArray decodes an array and stores it through p, that is, p points to the zeroth element.
 // The length is an unsigned integer preceding the elements.  Even though the length is redundant
 // (it's part of the type), it's a useful check and is included in the encoding.
-func (dec *Decoder) decodeArray(atyp reflect.Type, state *decoderState, p uintptr, elemOp decOp, elemWid uintptr, length, indir, elemIndir int, ovfl os.Error) {
+func (dec *Decoder) decodeArray(atyp reflect.Type, state *decoderState, p uintptr, elemOp decOp, elemWid uintptr, length, indir, elemIndir int, ovfl error) {
 	if indir > 0 {
 		p = allocate(atyp, p, 1) // All but the last level has been allocated by dec.Indirect
 	}
@@ -583,7 +583,7 @@
 
 // decodeIntoValue is a helper for map decoding.  Since maps are decoded using reflection,
 // unlike the other items we can't use a pointer directly.
-func decodeIntoValue(state *decoderState, op decOp, indir int, v reflect.Value, ovfl os.Error) reflect.Value {
+func decodeIntoValue(state *decoderState, op decOp, indir int, v reflect.Value, ovfl error) reflect.Value {
 	instr := &decInstr{op, 0, indir, 0, ovfl}
 	up := unsafe.Pointer(unsafeAddr(v))
 	if indir > 1 {
@@ -597,7 +597,7 @@
 // Maps are encoded as a length followed by key:value pairs.
 // Because the internals of maps are not visible to us, we must
 // use reflection rather than pointer magic.
-func (dec *Decoder) decodeMap(mtyp reflect.Type, state *decoderState, p uintptr, keyOp, elemOp decOp, indir, keyIndir, elemIndir int, ovfl os.Error) {
+func (dec *Decoder) decodeMap(mtyp reflect.Type, state *decoderState, p uintptr, keyOp, elemOp decOp, indir, keyIndir, elemIndir int, ovfl error) {
 	if indir > 0 {
 		p = allocate(mtyp, p, 1) // All but the last level has been allocated by dec.Indirect
 	}
@@ -620,7 +620,7 @@
 
 // ignoreArrayHelper does the work for discarding arrays and slices.
 func (dec *Decoder) ignoreArrayHelper(state *decoderState, elemOp decOp, length int) {
-	instr := &decInstr{elemOp, 0, 0, 0, os.NewError("no error")}
+	instr := &decInstr{elemOp, 0, 0, 0, errors.New("no error")}
 	for i := 0; i < length; i++ {
 		elemOp(instr, state, nil)
 	}
@@ -637,8 +637,8 @@
 // ignoreMap discards the data for a map value with no destination.
 func (dec *Decoder) ignoreMap(state *decoderState, keyOp, elemOp decOp) {
 	n := int(state.decodeUint())
-	keyInstr := &decInstr{keyOp, 0, 0, 0, os.NewError("no error")}
-	elemInstr := &decInstr{elemOp, 0, 0, 0, os.NewError("no error")}
+	keyInstr := &decInstr{keyOp, 0, 0, 0, errors.New("no error")}
+	elemInstr := &decInstr{elemOp, 0, 0, 0, errors.New("no error")}
 	for i := 0; i < n; i++ {
 		keyOp(keyInstr, state, nil)
 		elemOp(elemInstr, state, nil)
@@ -647,7 +647,7 @@
 
 // decodeSlice decodes a slice and stores the slice header through p.
 // Slices are encoded as an unsigned length followed by the elements.
-func (dec *Decoder) decodeSlice(atyp reflect.Type, state *decoderState, p uintptr, elemOp decOp, elemWid uintptr, indir, elemIndir int, ovfl os.Error) {
+func (dec *Decoder) decodeSlice(atyp reflect.Type, state *decoderState, p uintptr, elemOp decOp, elemWid uintptr, indir, elemIndir int, ovfl error) {
 	n := int(uintptr(state.decodeUint()))
 	if indir > 0 {
 		up := unsafe.Pointer(p)
@@ -707,7 +707,7 @@
 	// Read the type id of the concrete value.
 	concreteId := dec.decodeTypeSequence(true)
 	if concreteId < 0 {
-		error(dec.err)
+		error_(dec.err)
 	}
 	// Byte count of value is next; we don't care what it is (it's there
 	// in case we want to ignore the value by skipping it completely).
@@ -716,7 +716,7 @@
 	value := allocValue(typ)
 	dec.decodeValue(concreteId, value)
 	if dec.err != nil {
-		error(dec.err)
+		error_(dec.err)
 	}
 	// Allocate the destination interface value.
 	if indir > 0 {
@@ -736,11 +736,11 @@
 	b := make([]byte, state.decodeUint())
 	_, err := state.b.Read(b)
 	if err != nil {
-		error(err)
+		error_(err)
 	}
 	id := dec.decodeTypeSequence(true)
 	if id < 0 {
-		error(dec.err)
+		error_(dec.err)
 	}
 	// At this point, the decoder buffer contains a delimited value. Just toss it.
 	state.b.Next(int(state.decodeUint()))
@@ -753,12 +753,12 @@
 	b := make([]byte, state.decodeUint())
 	_, err := state.b.Read(b)
 	if err != nil {
-		error(err)
+		error_(err)
 	}
 	// We know it's a GobDecoder, so just call the method directly.
 	err = v.Interface().(GobDecoder).GobDecode(b)
 	if err != nil {
-		error(err)
+		error_(err)
 	}
 }
 
@@ -768,7 +768,7 @@
 	b := make([]byte, state.decodeUint())
 	_, err := state.b.Read(b)
 	if err != nil {
-		error(err)
+		error_(err)
 	}
 }
 
@@ -868,7 +868,7 @@
 			// Generate a closure that calls out to the engine for the nested type.
 			enginePtr, err := dec.getDecEnginePtr(wireId, userType(typ))
 			if err != nil {
-				error(err)
+				error_(err)
 			}
 			op = func(i *decInstr, state *decoderState, p unsafe.Pointer) {
 				// indirect through enginePtr to delay evaluation for recursive structs.
@@ -930,7 +930,7 @@
 			// Generate a closure that calls out to the engine for the nested type.
 			enginePtr, err := dec.getIgnoreEnginePtr(wireId)
 			if err != nil {
-				error(err)
+				error_(err)
 			}
 			op = func(i *decInstr, state *decoderState, p unsafe.Pointer) {
 				// indirect through enginePtr to delay evaluation for recursive structs
@@ -1062,23 +1062,23 @@
 
 // compileSingle compiles the decoder engine for a non-struct top-level value, including
 // GobDecoders.
-func (dec *Decoder) compileSingle(remoteId typeId, ut *userTypeInfo) (engine *decEngine, err os.Error) {
+func (dec *Decoder) compileSingle(remoteId typeId, ut *userTypeInfo) (engine *decEngine, err error) {
 	rt := ut.user
 	engine = new(decEngine)
 	engine.instr = make([]decInstr, 1) // one item
 	name := rt.String()                // best we can do
 	if !dec.compatibleType(rt, remoteId, make(map[reflect.Type]typeId)) {
-		return nil, os.NewError("gob: wrong type received for local value " + name + ": " + dec.typeString(remoteId))
+		return nil, errors.New("gob: wrong type received for local value " + name + ": " + dec.typeString(remoteId))
 	}
 	op, indir := dec.decOpFor(remoteId, rt, name, make(map[reflect.Type]*decOp))
-	ovfl := os.NewError(`value for "` + name + `" out of range`)
+	ovfl := errors.New(`value for "` + name + `" out of range`)
 	engine.instr[singletonField] = decInstr{*op, singletonField, indir, 0, ovfl}
 	engine.numInstr = 1
 	return
 }
 
 // compileIgnoreSingle compiles the decoder engine for a non-struct top-level value that will be discarded.
-func (dec *Decoder) compileIgnoreSingle(remoteId typeId) (engine *decEngine, err os.Error) {
+func (dec *Decoder) compileIgnoreSingle(remoteId typeId) (engine *decEngine, err error) {
 	engine = new(decEngine)
 	engine.instr = make([]decInstr, 1) // one item
 	op := dec.decIgnoreOpFor(remoteId)
@@ -1090,7 +1090,7 @@
 
 // compileDec compiles the decoder engine for a value.  If the value is not a struct,
 // it calls out to compileSingle.
-func (dec *Decoder) compileDec(remoteId typeId, ut *userTypeInfo) (engine *decEngine, err os.Error) {
+func (dec *Decoder) compileDec(remoteId typeId, ut *userTypeInfo) (engine *decEngine, err error) {
 	rt := ut.base
 	srt := rt
 	if srt.Kind() != reflect.Struct ||
@@ -1105,7 +1105,7 @@
 	} else {
 		wire := dec.wireType[remoteId]
 		if wire == nil {
-			error(errBadType)
+			error_(errBadType)
 		}
 		wireStruct = wire.StructT
 	}
@@ -1141,7 +1141,7 @@
 }
 
 // getDecEnginePtr returns the engine for the specified type.
-func (dec *Decoder) getDecEnginePtr(remoteId typeId, ut *userTypeInfo) (enginePtr **decEngine, err os.Error) {
+func (dec *Decoder) getDecEnginePtr(remoteId typeId, ut *userTypeInfo) (enginePtr **decEngine, err error) {
 	rt := ut.base
 	decoderMap, ok := dec.decoderCache[rt]
 	if !ok {
@@ -1166,7 +1166,7 @@
 var emptyStructType = reflect.TypeOf(emptyStruct{})
 
 // getDecEnginePtr returns the engine for the specified type when the value is to be discarded.
-func (dec *Decoder) getIgnoreEnginePtr(wireId typeId) (enginePtr **decEngine, err os.Error) {
+func (dec *Decoder) getIgnoreEnginePtr(wireId typeId) (enginePtr **decEngine, err error) {
 	var ok bool
 	if enginePtr, ok = dec.ignorerCache[wireId]; !ok {
 		// To handle recursive types, mark this engine as underway before compiling.
diff --git a/src/pkg/gob/decoder.go b/src/pkg/gob/decoder.go
index 1d526e3..5e684d3 100644
--- a/src/pkg/gob/decoder.go
+++ b/src/pkg/gob/decoder.go
@@ -7,8 +7,8 @@
 import (
 	"bufio"
 	"bytes"
+	"errors"
 	"io"
-	"os"
 	"reflect"
 	"sync"
 )
@@ -25,7 +25,7 @@
 	freeList     *decoderState                           // list of free decoderStates; avoids reallocation
 	countBuf     []byte                                  // used for decoding integers while parsing messages
 	tmp          []byte                                  // temporary storage for i/o; saves reallocating
-	err          os.Error
+	err          error
 }
 
 // NewDecoder returns a new decoder that reads from the io.Reader.
@@ -50,7 +50,7 @@
 func (dec *Decoder) recvType(id typeId) {
 	// Have we already seen this type?  That's an error
 	if id < firstUserId || dec.wireType[id] != nil {
-		dec.err = os.NewError("gob: duplicate type received")
+		dec.err = errors.New("gob: duplicate type received")
 		return
 	}
 
@@ -64,7 +64,7 @@
 	dec.wireType[id] = wire
 }
 
-var errBadCount = os.NewError("invalid message length")
+var errBadCount = errors.New("invalid message length")
 
 // recvMessage reads the next count-delimited item from the input. It is the converse
 // of Encoder.writeMessage. It returns false on EOF or other error reading the message.
@@ -94,7 +94,7 @@
 	// Read the data
 	_, dec.err = io.ReadFull(dec.r, dec.tmp)
 	if dec.err != nil {
-		if dec.err == os.EOF {
+		if dec.err == io.EOF {
 			dec.err = io.ErrUnexpectedEOF
 		}
 		return
@@ -155,7 +155,7 @@
 		// will be absorbed by recvMessage.)
 		if dec.buf.Len() > 0 {
 			if !isInterface {
-				dec.err = os.NewError("extra data in buffer")
+				dec.err = errors.New("extra data in buffer")
 				break
 			}
 			dec.nextUint()
@@ -169,7 +169,7 @@
 // If e is nil, the value will be discarded. Otherwise,
 // the value underlying e must be a pointer to the
 // correct type for the next data item received.
-func (dec *Decoder) Decode(e interface{}) os.Error {
+func (dec *Decoder) Decode(e interface{}) error {
 	if e == nil {
 		return dec.DecodeValue(reflect.Value{})
 	}
@@ -177,7 +177,7 @@
 	// If e represents a value as opposed to a pointer, the answer won't
 	// get back to the caller.  Make sure it's a pointer.
 	if value.Type().Kind() != reflect.Ptr {
-		dec.err = os.NewError("gob: attempt to decode into a non-pointer")
+		dec.err = errors.New("gob: attempt to decode into a non-pointer")
 		return dec.err
 	}
 	return dec.DecodeValue(value)
@@ -187,12 +187,12 @@
 // If v is the zero reflect.Value (v.Kind() == Invalid), DecodeValue discards the value.
 // Otherwise, it stores the value into v.  In that case, v must represent
 // a non-nil pointer to data or be an assignable reflect.Value (v.CanSet())
-func (dec *Decoder) DecodeValue(v reflect.Value) os.Error {
+func (dec *Decoder) DecodeValue(v reflect.Value) error {
 	if v.IsValid() {
 		if v.Kind() == reflect.Ptr && !v.IsNil() {
 			// That's okay, we'll store through the pointer.
 		} else if !v.CanSet() {
-			return os.NewError("gob: DecodeValue of unassignable value")
+			return errors.New("gob: DecodeValue of unassignable value")
 		}
 	}
 	// Make sure we're single-threaded through here.
diff --git a/src/pkg/gob/dump.go b/src/pkg/gob/dump.go
index 1555f0f..c4d4331 100644
--- a/src/pkg/gob/dump.go
+++ b/src/pkg/gob/dump.go
@@ -9,7 +9,7 @@
 )
 
 func main() {
-	var err os.Error
+	var err error
 	file := os.Stdin
 	if len(os.Args) > 1 {
 		file, err = os.Open(os.Args[1])
diff --git a/src/pkg/gob/encode.go b/src/pkg/gob/encode.go
index c164435..c7e4823 100644
--- a/src/pkg/gob/encode.go
+++ b/src/pkg/gob/encode.go
@@ -55,7 +55,7 @@
 	if x <= 0x7F {
 		err := state.b.WriteByte(uint8(x))
 		if err != nil {
-			error(err)
+			error_(err)
 		}
 		return
 	}
@@ -68,7 +68,7 @@
 	state.buf[i] = uint8(i - uint64Size) // = loop count, negated
 	_, err := state.b.Write(state.buf[i : uint64Size+1])
 	if err != nil {
-		error(err)
+		error_(err)
 	}
 }
 
@@ -443,7 +443,7 @@
 	state.encodeUint(uint64(len(name)))
 	_, err := state.b.WriteString(name)
 	if err != nil {
-		error(err)
+		error_(err)
 	}
 	// Define the type id if necessary.
 	enc.sendTypeDescriptor(enc.writer(), state, ut)
@@ -456,12 +456,12 @@
 	data.Write(spaceForLength)
 	enc.encode(data, iv.Elem(), ut)
 	if enc.err != nil {
-		error(enc.err)
+		error_(enc.err)
 	}
 	enc.popWriter()
 	enc.writeMessage(b, data)
 	if enc.err != nil {
-		error(err)
+		error_(err)
 	}
 	enc.freeEncoderState(state)
 }
@@ -494,7 +494,7 @@
 	// We know it's a GobEncoder, so just call the method directly.
 	data, err := v.Interface().(GobEncoder).GobEncode()
 	if err != nil {
-		error(err)
+		error_(err)
 	}
 	state := enc.newEncoderState(b)
 	state.fieldnum = -1
@@ -681,7 +681,7 @@
 func (enc *Encoder) getEncEngine(ut *userTypeInfo) *encEngine {
 	info, err1 := getTypeInfo(ut)
 	if err1 != nil {
-		error(err1)
+		error_(err1)
 	}
 	if info.encoder == nil {
 		// mark this engine as underway before compiling to handle recursive types.
diff --git a/src/pkg/gob/encoder.go b/src/pkg/gob/encoder.go
index 878d082..e4a48df 100644
--- a/src/pkg/gob/encoder.go
+++ b/src/pkg/gob/encoder.go
@@ -6,8 +6,8 @@
 
 import (
 	"bytes"
+	"errors"
 	"io"
-	"os"
 	"reflect"
 	"sync"
 )
@@ -21,7 +21,7 @@
 	countState *encoderState           // stage for writing counts
 	freeList   *encoderState           // list of free encoderStates; avoids reallocation
 	byteBuf    bytes.Buffer            // buffer for top-level encoderState
-	err        os.Error
+	err        error
 }
 
 // Before we encode a message, we reserve space at the head of the
@@ -55,10 +55,10 @@
 }
 
 func (enc *Encoder) badType(rt reflect.Type) {
-	enc.setError(os.NewError("gob: can't encode type " + rt.String()))
+	enc.setError(errors.New("gob: can't encode type " + rt.String()))
 }
 
-func (enc *Encoder) setError(err os.Error) {
+func (enc *Encoder) setError(err error) {
 	if enc.err == nil { // remember the first.
 		enc.err = err
 	}
@@ -171,7 +171,7 @@
 
 // Encode transmits the data item represented by the empty interface value,
 // guaranteeing that all necessary type information has been transmitted first.
-func (enc *Encoder) Encode(e interface{}) os.Error {
+func (enc *Encoder) Encode(e interface{}) error {
 	return enc.EncodeValue(reflect.ValueOf(e))
 }
 
@@ -215,7 +215,7 @@
 
 // EncodeValue transmits the data item represented by the reflection value,
 // guaranteeing that all necessary type information has been transmitted first.
-func (enc *Encoder) EncodeValue(value reflect.Value) os.Error {
+func (enc *Encoder) EncodeValue(value reflect.Value) error {
 	// Make sure we're single-threaded through here, so multiple
 	// goroutines can share an encoder.
 	enc.mutex.Lock()
diff --git a/src/pkg/gob/encoder_test.go b/src/pkg/gob/encoder_test.go
index 98c0c97..bc5af12 100644
--- a/src/pkg/gob/encoder_test.go
+++ b/src/pkg/gob/encoder_test.go
@@ -8,7 +8,6 @@
 	"bytes"
 	"fmt"
 	"io"
-	"os"
 	"reflect"
 	"strings"
 	"testing"
@@ -116,7 +115,7 @@
 	badTypeCheck(new(ET4), true, "different type of field", t)
 }
 
-func corruptDataCheck(s string, err os.Error, t *testing.T) {
+func corruptDataCheck(s string, err error, t *testing.T) {
 	b := bytes.NewBufferString(s)
 	dec := NewDecoder(b)
 	err1 := dec.Decode(new(ET2))
@@ -127,7 +126,7 @@
 
 // Check that we survive bad data.
 func TestBadData(t *testing.T) {
-	corruptDataCheck("", os.EOF, t)
+	corruptDataCheck("", io.EOF, t)
 	corruptDataCheck("\x7Fhi", io.ErrUnexpectedEOF, t)
 	corruptDataCheck("\x03now is the time for all good men", errBadType, t)
 }
@@ -149,7 +148,7 @@
 	}
 }
 
-func encAndDec(in, out interface{}) os.Error {
+func encAndDec(in, out interface{}) error {
 	b := new(bytes.Buffer)
 	enc := NewEncoder(b)
 	err := enc.Encode(in)
@@ -225,7 +224,7 @@
 	}
 	t4p := &Type4{3}
 	var t4 Type4 // note: not a pointer.
-	if err := encAndDec(t4p, t4); err == nil || strings.Index(err.String(), "pointer") < 0 {
+	if err := encAndDec(t4p, t4); err == nil || strings.Index(err.Error(), "pointer") < 0 {
 		t.Error("expected error about pointer; got", err)
 	}
 }
@@ -333,7 +332,7 @@
 			t.Errorf("expected error decoding %v: %s", test.in, test.err)
 			continue
 		case err != nil && test.err != "":
-			if strings.Index(err.String(), test.err) < 0 {
+			if strings.Index(err.Error(), test.err) < 0 {
 				t.Errorf("wrong error decoding %v: wanted %s, got %v", test.in, test.err, err)
 			}
 			continue
@@ -359,7 +358,7 @@
 	var ns NonStruct
 	if err := encAndDec(s, &ns); err == nil {
 		t.Error("should get error for struct/non-struct")
-	} else if strings.Index(err.String(), "type") < 0 {
+	} else if strings.Index(err.Error(), "type") < 0 {
 		t.Error("for struct/non-struct expected type error; got", err)
 	}
 	// Now try the other way
@@ -369,7 +368,7 @@
 	}
 	if err := encAndDec(ns, &s); err == nil {
 		t.Error("should get error for non-struct/struct")
-	} else if strings.Index(err.String(), "type") < 0 {
+	} else if strings.Index(err.Error(), "type") < 0 {
 		t.Error("for non-struct/struct expected type error; got", err)
 	}
 }
@@ -524,7 +523,7 @@
 
 type Bug1StructMap map[string]Bug1Elem
 
-func bug1EncDec(in Bug1StructMap, out *Bug1StructMap) os.Error {
+func bug1EncDec(in Bug1StructMap, out *Bug1StructMap) error {
 	return nil
 }
 
@@ -634,7 +633,7 @@
 	b := []byte{0xfb, 0xa5, 0x82, 0x2f, 0xca, 0x1}
 	if err := NewDecoder(bytes.NewBuffer(b)).Decode(nil); err == nil {
 		t.Error("expected error from bad count")
-	} else if err.String() != errBadCount.String() {
+	} else if err.Error() != errBadCount.Error() {
 		t.Error("expected bad count error; got", err)
 	}
 }
diff --git a/src/pkg/gob/error.go b/src/pkg/gob/error.go
index 106543d..b0c4008 100644
--- a/src/pkg/gob/error.go
+++ b/src/pkg/gob/error.go
@@ -4,10 +4,7 @@
 
 package gob
 
-import (
-	"fmt"
-	"os"
-)
+import "fmt"
 
 // Errors in decoding and encoding are handled using panic and recover.
 // Panics caused by user error (that is, everything except run-time panics
@@ -18,23 +15,23 @@
 
 // A gobError wraps an os.Error and is used to distinguish errors (panics) generated in this package.
 type gobError struct {
-	err os.Error
+	err error
 }
 
 // errorf is like error but takes Printf-style arguments to construct an os.Error.
 // It always prefixes the message with "gob: ".
 func errorf(format string, args ...interface{}) {
-	error(fmt.Errorf("gob: "+format, args...))
+	error_(fmt.Errorf("gob: "+format, args...))
 }
 
 // error wraps the argument error and uses it as the argument to panic.
-func error(err os.Error) {
+func error_(err error) {
 	panic(gobError{err})
 }
 
 // catchError is meant to be used as a deferred function to turn a panic(gobError) into a
 // plain os.Error.  It overwrites the error return of the function that deferred its call.
-func catchError(err *os.Error) {
+func catchError(err *error) {
 	if e := recover(); e != nil {
 		*err = e.(gobError).err // Will re-panic if not one of our errors, such as a runtime error.
 	}
diff --git a/src/pkg/gob/gobencdec_test.go b/src/pkg/gob/gobencdec_test.go
index 01addbe..eacfd84 100644
--- a/src/pkg/gob/gobencdec_test.go
+++ b/src/pkg/gob/gobencdec_test.go
@@ -8,8 +8,9 @@
 
 import (
 	"bytes"
+	"errors"
 	"fmt"
-	"os"
+	"io"
 	"strings"
 	"testing"
 )
@@ -34,7 +35,7 @@
 
 // The relevant methods
 
-func (g *ByteStruct) GobEncode() ([]byte, os.Error) {
+func (g *ByteStruct) GobEncode() ([]byte, error) {
 	b := make([]byte, 3)
 	b[0] = g.a
 	b[1] = g.a + 1
@@ -42,68 +43,68 @@
 	return b, nil
 }
 
-func (g *ByteStruct) GobDecode(data []byte) os.Error {
+func (g *ByteStruct) GobDecode(data []byte) error {
 	if g == nil {
-		return os.NewError("NIL RECEIVER")
+		return errors.New("NIL RECEIVER")
 	}
 	// Expect N sequential-valued bytes.
 	if len(data) == 0 {
-		return os.EOF
+		return io.EOF
 	}
 	g.a = data[0]
 	for i, c := range data {
 		if c != g.a+byte(i) {
-			return os.NewError("invalid data sequence")
+			return errors.New("invalid data sequence")
 		}
 	}
 	return nil
 }
 
-func (g *StringStruct) GobEncode() ([]byte, os.Error) {
+func (g *StringStruct) GobEncode() ([]byte, error) {
 	return []byte(g.s), nil
 }
 
-func (g *StringStruct) GobDecode(data []byte) os.Error {
+func (g *StringStruct) GobDecode(data []byte) error {
 	// Expect N sequential-valued bytes.
 	if len(data) == 0 {
-		return os.EOF
+		return io.EOF
 	}
 	a := data[0]
 	for i, c := range data {
 		if c != a+byte(i) {
-			return os.NewError("invalid data sequence")
+			return errors.New("invalid data sequence")
 		}
 	}
 	g.s = string(data)
 	return nil
 }
 
-func (a *ArrayStruct) GobEncode() ([]byte, os.Error) {
+func (a *ArrayStruct) GobEncode() ([]byte, error) {
 	return a.a[:], nil
 }
 
-func (a *ArrayStruct) GobDecode(data []byte) os.Error {
+func (a *ArrayStruct) GobDecode(data []byte) error {
 	if len(data) != len(a.a) {
-		return os.NewError("wrong length in array decode")
+		return errors.New("wrong length in array decode")
 	}
 	copy(a.a[:], data)
 	return nil
 }
 
-func (g *Gobber) GobEncode() ([]byte, os.Error) {
+func (g *Gobber) GobEncode() ([]byte, error) {
 	return []byte(fmt.Sprintf("VALUE=%d", *g)), nil
 }
 
-func (g *Gobber) GobDecode(data []byte) os.Error {
+func (g *Gobber) GobDecode(data []byte) error {
 	_, err := fmt.Sscanf(string(data), "VALUE=%d", (*int)(g))
 	return err
 }
 
-func (v ValueGobber) GobEncode() ([]byte, os.Error) {
+func (v ValueGobber) GobEncode() ([]byte, error) {
 	return []byte(fmt.Sprintf("VALUE=%s", v)), nil
 }
 
-func (v *ValueGobber) GobDecode(data []byte) os.Error {
+func (v *ValueGobber) GobDecode(data []byte) error {
 	_, err := fmt.Sscanf(string(data), "VALUE=%s", (*string)(v))
 	return err
 }
@@ -372,7 +373,7 @@
 	if err == nil {
 		t.Fatal("expected decode error for mismatched fields (encoder to non-decoder)")
 	}
-	if strings.Index(err.String(), "type") < 0 {
+	if strings.Index(err.Error(), "type") < 0 {
 		t.Fatal("expected type error; got", err)
 	}
 	// Non-encoder to GobDecoder: error
@@ -386,7 +387,7 @@
 	if err == nil {
 		t.Fatal("expected decode error for mismatched fields (non-encoder to decoder)")
 	}
-	if strings.Index(err.String(), "type") < 0 {
+	if strings.Index(err.Error(), "type") < 0 {
 		t.Fatal("expected type error; got", err)
 	}
 }
@@ -497,11 +498,11 @@
 	return br.foo + "-" + br.bar
 }
 
-func (br *gobDecoderBug0) GobEncode() ([]byte, os.Error) {
+func (br *gobDecoderBug0) GobEncode() ([]byte, error) {
 	return []byte(br.String()), nil
 }
 
-func (br *gobDecoderBug0) GobDecode(b []byte) os.Error {
+func (br *gobDecoderBug0) GobDecode(b []byte) error {
 	br.foo = "foo"
 	br.bar = "bar"
 	return nil
diff --git a/src/pkg/gob/timing_test.go b/src/pkg/gob/timing_test.go
index 2a2be73..47437a6 100644
--- a/src/pkg/gob/timing_test.go
+++ b/src/pkg/gob/timing_test.go
@@ -39,7 +39,7 @@
 func BenchmarkEndToEndPipe(b *testing.B) {
 	r, w, err := os.Pipe()
 	if err != nil {
-		panic("can't get pipe:" + err.String())
+		panic("can't get pipe:" + err.Error())
 	}
 	benchmarkEndToEnd(r, w, b)
 }
diff --git a/src/pkg/gob/type.go b/src/pkg/gob/type.go
index 870101e..c3bc7c7 100644
--- a/src/pkg/gob/type.go
+++ b/src/pkg/gob/type.go
@@ -5,6 +5,7 @@
 package gob
 
 import (
+	"errors"
 	"fmt"
 	"os"
 	"reflect"
@@ -36,7 +37,7 @@
 // validType returns, and saves, the information associated with user-provided type rt.
 // If the user type is not valid, err will be non-nil.  To be used when the error handler
 // is not set up.
-func validUserType(rt reflect.Type) (ut *userTypeInfo, err os.Error) {
+func validUserType(rt reflect.Type) (ut *userTypeInfo, err error) {
 	userTypeLock.RLock()
 	ut = userTypeCache[rt]
 	userTypeLock.RUnlock()
@@ -67,7 +68,7 @@
 		ut.base = pt.Elem()
 		if ut.base == slowpoke { // ut.base lapped slowpoke
 			// recursive pointer type.
-			return nil, os.NewError("can't represent recursive pointer type " + ut.base.String())
+			return nil, errors.New("can't represent recursive pointer type " + ut.base.String())
 		}
 		if ut.indir%2 == 0 {
 			slowpoke = slowpoke.Elem()
@@ -125,7 +126,7 @@
 func userType(rt reflect.Type) *userTypeInfo {
 	ut, err := validUserType(rt)
 	if err != nil {
-		error(err)
+		error_(err)
 	}
 	return ut
 }
@@ -396,12 +397,12 @@
 // of ut.
 // This is only called from the encoding side. The decoding side
 // works through typeIds and userTypeInfos alone.
-func newTypeObject(name string, ut *userTypeInfo, rt reflect.Type) (gobType, os.Error) {
+func newTypeObject(name string, ut *userTypeInfo, rt reflect.Type) (gobType, error) {
 	// Does this type implement GobEncoder?
 	if ut.isGobEncoder {
 		return newGobEncoderType(name), nil
 	}
-	var err os.Error
+	var err error
 	var type0, type1 gobType
 	defer func() {
 		if err != nil {
@@ -503,7 +504,7 @@
 		return st, nil
 
 	default:
-		return nil, os.NewError("gob NewTypeObject can't handle type: " + rt.String())
+		return nil, errors.New("gob NewTypeObject can't handle type: " + rt.String())
 	}
 	return nil, nil
 }
@@ -516,7 +517,7 @@
 
 // getBaseType returns the Gob type describing the given reflect.Type's base type.
 // typeLock must be held.
-func getBaseType(name string, rt reflect.Type) (gobType, os.Error) {
+func getBaseType(name string, rt reflect.Type) (gobType, error) {
 	ut := userType(rt)
 	return getType(name, ut, ut.base)
 }
@@ -526,7 +527,7 @@
 // which may be pointers.  All other types are handled through the
 // base type, never a pointer.
 // typeLock must be held.
-func getType(name string, ut *userTypeInfo, rt reflect.Type) (gobType, os.Error) {
+func getType(name string, ut *userTypeInfo, rt reflect.Type) (gobType, error) {
 	typ, present := types[rt]
 	if present {
 		return typ, nil
@@ -609,7 +610,7 @@
 var typeInfoMap = make(map[reflect.Type]*typeInfo) // protected by typeLock
 
 // typeLock must be held.
-func getTypeInfo(ut *userTypeInfo) (*typeInfo, os.Error) {
+func getTypeInfo(ut *userTypeInfo) (*typeInfo, error) {
 	rt := ut.base
 	if ut.isGobEncoder {
 		// We want the user type, not the base type.
@@ -658,7 +659,7 @@
 func mustGetTypeInfo(rt reflect.Type) *typeInfo {
 	t, err := getTypeInfo(userType(rt))
 	if err != nil {
-		panic("getTypeInfo: " + err.String())
+		panic("getTypeInfo: " + err.Error())
 	}
 	return t
 }
@@ -678,7 +679,7 @@
 	// GobEncode returns a byte slice representing the encoding of the
 	// receiver for transmission to a GobDecoder, usually of the same
 	// concrete type.
-	GobEncode() ([]byte, os.Error)
+	GobEncode() ([]byte, error)
 }
 
 // GobDecoder is the interface describing data that provides its own
@@ -687,7 +688,7 @@
 	// GobDecode overwrites the receiver, which must be a pointer,
 	// with the value represented by the byte slice, which was written
 	// by GobEncode, usually for the same concrete type.
-	GobDecode([]byte) os.Error
+	GobDecode([]byte) error
 }
 
 var (
diff --git a/src/pkg/gob/type_test.go b/src/pkg/gob/type_test.go
index 411ffb7..a6ac9c4 100644
--- a/src/pkg/gob/type_test.go
+++ b/src/pkg/gob/type_test.go
@@ -28,7 +28,7 @@
 	defer typeLock.Unlock()
 	t, err := getBaseType(name, rt)
 	if err != nil {
-		panic("getTypeUnlocked: " + err.String())
+		panic("getTypeUnlocked: " + err.Error())
 	}
 	return t
 }