summaryrefslogtreecommitdiff
path: root/src/pkg/encoding
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/encoding')
-rw-r--r--src/pkg/encoding/ascii85/ascii85.go12
-rw-r--r--src/pkg/encoding/base64/base64.go8
-rw-r--r--src/pkg/encoding/binary/binary.go40
-rw-r--r--src/pkg/encoding/git85/git.go12
-rw-r--r--src/pkg/encoding/hex/hex.go12
5 files changed, 21 insertions, 63 deletions
diff --git a/src/pkg/encoding/ascii85/ascii85.go b/src/pkg/encoding/ascii85/ascii85.go
index adf1fe7dd..a1d9f7a7a 100644
--- a/src/pkg/encoding/ascii85/ascii85.go
+++ b/src/pkg/encoding/ascii85/ascii85.go
@@ -84,18 +84,14 @@ func Encode(dst, src []byte) int {
}
// MaxEncodedLen returns the maximum length of an encoding of n source bytes.
-func MaxEncodedLen(n int) int {
- return (n+3)/4*5;
-}
+func MaxEncodedLen(n int) int { return (n+3)/4*5 }
// NewEncoder returns a new ascii85 stream encoder. Data written to
// the returned writer will be encoded and then written to w.
// Ascii85 encodings operate in 32-bit blocks; when finished
// writing, the caller must Close the returned encoder to flush any
// trailing partial block.
-func NewEncoder(w io.Writer) io.WriteCloser {
- return &encoder{w: w};
-}
+func NewEncoder(w io.Writer) io.WriteCloser { return &encoder{w: w} }
type encoder struct {
err os.Error;
@@ -248,9 +244,7 @@ func Decode(dst, src []byte, flush bool) (ndst, nsrc int, err os.Error) {
}
// NewDecoder constructs a new ascii85 stream decoder.
-func NewDecoder(r io.Reader) io.Reader {
- return &decoder{r: r};
-}
+func NewDecoder(r io.Reader) io.Reader { return &decoder{r: r} }
type decoder struct {
err os.Error;
diff --git a/src/pkg/encoding/base64/base64.go b/src/pkg/encoding/base64/base64.go
index 9079f74fe..33010aa1b 100644
--- a/src/pkg/encoding/base64/base64.go
+++ b/src/pkg/encoding/base64/base64.go
@@ -189,9 +189,7 @@ func NewEncoder(enc *Encoding, w io.Writer) io.WriteCloser {
// EncodedLen returns the length in bytes of the base64 encoding
// of an input buffer of length n.
-func (enc *Encoding) EncodedLen(n int) int {
- return (n+2)/3*4;
-}
+func (enc *Encoding) EncodedLen(n int) int { return (n+2)/3*4 }
/*
* Decoder
@@ -329,6 +327,4 @@ func NewDecoder(enc *Encoding, r io.Reader) io.Reader {
// DecodeLen returns the maximum length in bytes of the decoded data
// corresponding to n bytes of base64-encoded data.
-func (enc *Encoding) DecodedLen(n int) int {
- return n/4*3;
-}
+func (enc *Encoding) DecodedLen(n int) int { return n/4*3 }
diff --git a/src/pkg/encoding/binary/binary.go b/src/pkg/encoding/binary/binary.go
index c49879c66..6907fa02c 100644
--- a/src/pkg/encoding/binary/binary.go
+++ b/src/pkg/encoding/binary/binary.go
@@ -34,9 +34,7 @@ var BigEndian ByteOrder = bigEndian(0)
type littleEndian unused
-func (littleEndian) Uint16(b []byte) uint16 {
- return uint16(b[0]) | uint16(b[1])<<8;
-}
+func (littleEndian) Uint16(b []byte) uint16 { return uint16(b[0]) | uint16(b[1])<<8 }
func (littleEndian) PutUint16(b []byte, v uint16) {
b[0] = byte(v);
@@ -70,19 +68,13 @@ func (littleEndian) PutUint64(b []byte, v uint64) {
b[7] = byte(v>>56);
}
-func (littleEndian) String() string {
- return "LittleEndian";
-}
+func (littleEndian) String() string { return "LittleEndian" }
-func (littleEndian) GoString() string {
- return "binary.LittleEndian";
-}
+func (littleEndian) GoString() string { return "binary.LittleEndian" }
type bigEndian unused
-func (bigEndian) Uint16(b []byte) uint16 {
- return uint16(b[1]) | uint16(b[0])<<8;
-}
+func (bigEndian) Uint16(b []byte) uint16 { return uint16(b[1]) | uint16(b[0])<<8 }
func (bigEndian) PutUint16(b []byte, v uint16) {
b[0] = byte(v>>8);
@@ -116,13 +108,9 @@ func (bigEndian) PutUint64(b []byte, v uint64) {
b[7] = byte(v);
}
-func (bigEndian) String() string {
- return "BigEndian";
-}
+func (bigEndian) String() string { return "BigEndian" }
-func (bigEndian) GoString() string {
- return "binary.BigEndian";
-}
+func (bigEndian) GoString() string { return "binary.BigEndian" }
// Read reads structured binary data from r into data.
// Data must be a pointer to a fixed-size value.
@@ -218,21 +206,13 @@ func (d *decoder) uint64() uint64 {
return x;
}
-func (d *decoder) int8() int8 {
- return int8(d.uint8());
-}
+func (d *decoder) int8() int8 { return int8(d.uint8()) }
-func (d *decoder) int16() int16 {
- return int16(d.uint16());
-}
+func (d *decoder) int16() int16 { return int16(d.uint16()) }
-func (d *decoder) int32() int32 {
- return int32(d.uint32());
-}
+func (d *decoder) int32() int32 { return int32(d.uint32()) }
-func (d *decoder) int64() int64 {
- return int64(d.uint64());
-}
+func (d *decoder) int64() int64 { return int64(d.uint64()) }
func (d *decoder) value(v reflect.Value) {
switch v := v.(type) {
diff --git a/src/pkg/encoding/git85/git.go b/src/pkg/encoding/git85/git.go
index 51e4654dd..e49251fb3 100644
--- a/src/pkg/encoding/git85/git.go
+++ b/src/pkg/encoding/git85/git.go
@@ -142,18 +142,14 @@ func Decode(dst, src []byte) (n int, err os.Error) {
return ndst, nil;
}
-func MaxDecodedLen(n int) int {
- return n/5*4;
-}
+func MaxDecodedLen(n int) int { return n/5*4 }
// NewEncoder returns a new GIT base85 stream encoder. Data written to
// the returned writer will be encoded and then written to w.
// The GIT encoding operates on 52-byte blocks; when finished
// writing, the caller must Close the returned encoder to flush any
// partially written blocks.
-func NewEncoder(w io.Writer) io.WriteCloser {
- return &encoder{w: w};
-}
+func NewEncoder(w io.Writer) io.WriteCloser { return &encoder{w: w} }
type encoder struct {
w io.Writer;
@@ -224,9 +220,7 @@ func (e *encoder) Close() os.Error {
}
// NewDecoder returns a new GIT base85 stream decoder.
-func NewDecoder(r io.Reader) io.Reader {
- return &decoder{r: r};
-}
+func NewDecoder(r io.Reader) io.Reader { return &decoder{r: r} }
type decoder struct {
r io.Reader;
diff --git a/src/pkg/encoding/hex/hex.go b/src/pkg/encoding/hex/hex.go
index 77aa13305..ff55dd489 100644
--- a/src/pkg/encoding/hex/hex.go
+++ b/src/pkg/encoding/hex/hex.go
@@ -14,9 +14,7 @@ import (
const hextable = "0123456789abcdef"
// EncodedLen returns the length of an encoding of n source bytes.
-func EncodedLen(n int) int {
- return n*2;
-}
+func EncodedLen(n int) int { return n*2 }
// Encode encodes src into EncodedLen(len(src))
// bytes of dst. As a convenience, it returns the number
@@ -34,9 +32,7 @@ func Encode(dst, src []byte) int {
// OddLengthInputError results from decoding an odd length slice.
type OddLengthInputError struct{}
-func (OddLengthInputError) String() string {
- return "odd length hex string";
-}
+func (OddLengthInputError) String() string { return "odd length hex string" }
// InvalidHexCharError results from finding an invalid character in a hex string.
type InvalidHexCharError byte
@@ -46,9 +42,7 @@ func (e InvalidHexCharError) String() string {
}
-func DecodedLen(x int) int {
- return x/2;
-}
+func DecodedLen(x int) int { return x/2 }
// Decode decodes src into DecodedLen(len(src)) bytes, returning the actual
// number of bytes written to dst.