summaryrefslogtreecommitdiff
path: root/src/pkg/encoding/base64/base64.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/encoding/base64/base64.go')
-rw-r--r--src/pkg/encoding/base64/base64.go21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/pkg/encoding/base64/base64.go b/src/pkg/encoding/base64/base64.go
index c6b2a13e4..889b565e3 100644
--- a/src/pkg/encoding/base64/base64.go
+++ b/src/pkg/encoding/base64/base64.go
@@ -7,7 +7,6 @@ package base64
import (
"io"
- "os"
"strconv"
)
@@ -114,7 +113,7 @@ func (enc *Encoding) EncodeToString(src []byte) string {
}
type encoder struct {
- err os.Error
+ err error
enc *Encoding
w io.Writer
buf [3]byte // buffered data waiting to be encoded
@@ -122,7 +121,7 @@ type encoder struct {
out [1024]byte // output buffer
}
-func (e *encoder) Write(p []byte) (n int, err os.Error) {
+func (e *encoder) Write(p []byte) (n int, err error) {
if e.err != nil {
return 0, e.err
}
@@ -174,7 +173,7 @@ func (e *encoder) Write(p []byte) (n int, err os.Error) {
// Close flushes any pending output from the encoder.
// It is an error to call Write after calling Close.
-func (e *encoder) Close() os.Error {
+func (e *encoder) Close() error {
// If there's anything left in the buffer, flush it out
if e.err == nil && e.nbuf > 0 {
e.enc.Encode(e.out[0:], e.buf[0:e.nbuf])
@@ -203,15 +202,15 @@ func (enc *Encoding) EncodedLen(n int) int { return (n + 2) / 3 * 4 }
type CorruptInputError int64
-func (e CorruptInputError) String() string {
- return "illegal base64 data at input byte " + strconv.Itoa64(int64(e))
+func (e CorruptInputError) Error() string {
+ return "illegal base64 data at input byte " + strconv.FormatInt(int64(e), 10)
}
// decode is like Decode but returns an additional 'end' value, which
// indicates if end-of-message padding was encountered and thus any
// additional data is an error. decode also assumes len(src)%4==0,
// since it is meant for internal use.
-func (enc *Encoding) decode(dst, src []byte) (n int, end bool, err os.Error) {
+func (enc *Encoding) decode(dst, src []byte) (n int, end bool, err error) {
for i := 0; i < len(src)/4 && !end; i++ {
// Decode quantum using the base64 alphabet
var dbuf [4]byte
@@ -258,7 +257,7 @@ func (enc *Encoding) decode(dst, src []byte) (n int, end bool, err os.Error) {
// DecodedLen(len(src)) bytes to dst and returns the number of bytes
// written. If src contains invalid base64 data, it will return the
// number of bytes successfully written and CorruptInputError.
-func (enc *Encoding) Decode(dst, src []byte) (n int, err os.Error) {
+func (enc *Encoding) Decode(dst, src []byte) (n int, err error) {
if len(src)%4 != 0 {
return 0, CorruptInputError(len(src) / 4 * 4)
}
@@ -268,14 +267,14 @@ func (enc *Encoding) Decode(dst, src []byte) (n int, err os.Error) {
}
// DecodeString returns the bytes represented by the base64 string s.
-func (enc *Encoding) DecodeString(s string) ([]byte, os.Error) {
+func (enc *Encoding) DecodeString(s string) ([]byte, error) {
dbuf := make([]byte, enc.DecodedLen(len(s)))
n, err := enc.Decode(dbuf, []byte(s))
return dbuf[:n], err
}
type decoder struct {
- err os.Error
+ err error
enc *Encoding
r io.Reader
end bool // saw end of message
@@ -285,7 +284,7 @@ type decoder struct {
outbuf [1024 / 4 * 3]byte
}
-func (d *decoder) Read(p []byte) (n int, err os.Error) {
+func (d *decoder) Read(p []byte) (n int, err error) {
if d.err != nil {
return 0, d.err
}