diff options
author | Russ Cox <rsc@golang.org> | 2009-10-06 19:41:51 -0700 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2009-10-06 19:41:51 -0700 |
commit | d55efed74b0a3bdd3e834fc6b6eaa491bfc836ad (patch) | |
tree | 2366cc62ab4dee2e5698d6d6e5b299d6819a7edd /src/pkg/hash | |
parent | 76a3c142559d64179205f756c6b70ed4616a3145 (diff) | |
download | go-d55efed74b0a3bdd3e834fc6b6eaa491bfc836ad.tar.gz |
apply gofmt to go, gob, hash, http, image, io, json, log
R=gri
DELTA=1359 (138 added, 32 deleted, 1189 changed)
OCL=35408
CL=35420
Diffstat (limited to 'src/pkg/hash')
-rw-r--r-- | src/pkg/hash/adler32/adler32_test.go | 71 | ||||
-rw-r--r-- | src/pkg/hash/crc32/crc32.go | 20 | ||||
-rw-r--r-- | src/pkg/hash/crc32/crc32_test.go | 69 | ||||
-rw-r--r-- | src/pkg/hash/hash.go | 3 |
4 files changed, 80 insertions, 83 deletions
diff --git a/src/pkg/hash/adler32/adler32_test.go b/src/pkg/hash/adler32/adler32_test.go index 87ca2e008..0197270b2 100644 --- a/src/pkg/hash/adler32/adler32_test.go +++ b/src/pkg/hash/adler32/adler32_test.go @@ -10,43 +10,43 @@ import ( ) type _Adler32Test struct { - out uint32; - in string; + out uint32; + in string; } -var golden = []_Adler32Test { - _Adler32Test{ 0x1, "" }, - _Adler32Test{ 0x620062, "a" }, - _Adler32Test{ 0x12600c4, "ab" }, - _Adler32Test{ 0x24d0127, "abc" }, - _Adler32Test{ 0x3d8018b, "abcd" }, - _Adler32Test{ 0x5c801f0, "abcde" }, - _Adler32Test{ 0x81e0256, "abcdef" }, - _Adler32Test{ 0xadb02bd, "abcdefg" }, - _Adler32Test{ 0xe000325, "abcdefgh" }, - _Adler32Test{ 0x118e038e, "abcdefghi" }, - _Adler32Test{ 0x158603f8, "abcdefghij" }, - _Adler32Test{ 0x3f090f02, "Discard medicine more than two years old." }, - _Adler32Test{ 0x46d81477, "He who has a shady past knows that nice guys finish last." }, - _Adler32Test{ 0x40ee0ee1, "I wouldn't marry him with a ten foot pole." }, - _Adler32Test{ 0x16661315, "Free! Free!/A trip/to Mars/for 900/empty jars/Burma Shave" }, - _Adler32Test{ 0x5b2e1480, "The days of the digital watch are numbered. -Tom Stoppard" }, - _Adler32Test{ 0x8c3c09ea, "Nepal premier won't resign." }, - _Adler32Test{ 0x45ac18fd, "For every action there is an equal and opposite government program." }, - _Adler32Test{ 0x53c61462, "His money is twice tainted: 'taint yours and 'taint mine." }, - _Adler32Test{ 0x7e511e63, "There is no reason for any individual to have a computer in their home. -Ken Olsen, 1977" }, - _Adler32Test{ 0xe4801a6a, "It's a tiny change to the code and not completely disgusting. - Bob Manchek" }, - _Adler32Test{ 0x61b507df, "size: a.out: bad magic" }, - _Adler32Test{ 0xb8631171, "The major problem is with sendmail. -Mark Horton" }, - _Adler32Test{ 0x8b5e1904, "Give me a rock, paper and scissors and I will move the world. CCFestoon" }, - _Adler32Test{ 0x7cc6102b, "If the enemy is within range, then so are you." }, - _Adler32Test{ 0x700318e7, "It's well we cannot hear the screams/That we create in others' dreams." }, - _Adler32Test{ 0x1e601747, "You remind me of a TV show, but that's all right: I watch it anyway." }, - _Adler32Test{ 0xb55b0b09, "C is as portable as Stonehedge!!" }, - _Adler32Test{ 0x39111dd0, "Even if I could be Shakespeare, I think I should still choose to be Faraday. - A. Huxley" }, - _Adler32Test{ 0x91dd304f, "The fugacity of a constituent in a mixture of gases at a given temperature is proportional to its mole fraction. Lewis-Randall Rule" }, - _Adler32Test{ 0x2e5d1316, "How can you write a big system without C++? -Paul Glick" }, - _Adler32Test{ 0xd0201df6, "'Invariant assertions' is the most elegant programming technique! -Tom Szymanski" }, +var golden = []_Adler32Test{ + _Adler32Test{0x1, ""}, + _Adler32Test{0x620062, "a"}, + _Adler32Test{0x12600c4, "ab"}, + _Adler32Test{0x24d0127, "abc"}, + _Adler32Test{0x3d8018b, "abcd"}, + _Adler32Test{0x5c801f0, "abcde"}, + _Adler32Test{0x81e0256, "abcdef"}, + _Adler32Test{0xadb02bd, "abcdefg"}, + _Adler32Test{0xe000325, "abcdefgh"}, + _Adler32Test{0x118e038e, "abcdefghi"}, + _Adler32Test{0x158603f8, "abcdefghij"}, + _Adler32Test{0x3f090f02, "Discard medicine more than two years old."}, + _Adler32Test{0x46d81477, "He who has a shady past knows that nice guys finish last."}, + _Adler32Test{0x40ee0ee1, "I wouldn't marry him with a ten foot pole."}, + _Adler32Test{0x16661315, "Free! Free!/A trip/to Mars/for 900/empty jars/Burma Shave"}, + _Adler32Test{0x5b2e1480, "The days of the digital watch are numbered. -Tom Stoppard"}, + _Adler32Test{0x8c3c09ea, "Nepal premier won't resign."}, + _Adler32Test{0x45ac18fd, "For every action there is an equal and opposite government program."}, + _Adler32Test{0x53c61462, "His money is twice tainted: 'taint yours and 'taint mine."}, + _Adler32Test{0x7e511e63, "There is no reason for any individual to have a computer in their home. -Ken Olsen, 1977"}, + _Adler32Test{0xe4801a6a, "It's a tiny change to the code and not completely disgusting. - Bob Manchek"}, + _Adler32Test{0x61b507df, "size: a.out: bad magic"}, + _Adler32Test{0xb8631171, "The major problem is with sendmail. -Mark Horton"}, + _Adler32Test{0x8b5e1904, "Give me a rock, paper and scissors and I will move the world. CCFestoon"}, + _Adler32Test{0x7cc6102b, "If the enemy is within range, then so are you."}, + _Adler32Test{0x700318e7, "It's well we cannot hear the screams/That we create in others' dreams."}, + _Adler32Test{0x1e601747, "You remind me of a TV show, but that's all right: I watch it anyway."}, + _Adler32Test{0xb55b0b09, "C is as portable as Stonehedge!!"}, + _Adler32Test{0x39111dd0, "Even if I could be Shakespeare, I think I should still choose to be Faraday. - A. Huxley"}, + _Adler32Test{0x91dd304f, "The fugacity of a constituent in a mixture of gases at a given temperature is proportional to its mole fraction. Lewis-Randall Rule"}, + _Adler32Test{0x2e5d1316, "How can you write a big system without C++? -Paul Glick"}, + _Adler32Test{0xd0201df6, "'Invariant assertions' is the most elegant programming technique! -Tom Szymanski"}, } func TestGolden(t *testing.T) { @@ -61,4 +61,3 @@ func TestGolden(t *testing.T) { } } } - diff --git a/src/pkg/hash/crc32/crc32.go b/src/pkg/hash/crc32/crc32.go index 22a0f68f6..2f5fb8f89 100644 --- a/src/pkg/hash/crc32/crc32.go +++ b/src/pkg/hash/crc32/crc32.go @@ -12,23 +12,23 @@ import ( ) // The size of a CRC-32 checksum in bytes. -const Size = 4; +const Size = 4 // Predefined polynomials. const ( // Far and away the most common CRC-32 polynomial. // Used by ethernet (IEEE 802.3), v.42, fddi, gzip, zip, png, mpeg-2, ... - IEEE = 0xedb88320; + IEEE = 0xedb88320; // Castagnoli's polynomial, used in iSCSI. // Has better error detection characteristics than IEEE. // http://dx.doi.org/10.1109/26.231911 - Castagnoli = 0x82f63b78; + Castagnoli = 0x82f63b78; // Koopman's polynomial. // Also has better error detection characteristics than IEEE. // http://dx.doi.org/10.1109/DSN.2002.1028931 - Koopman = 0xeb31d82e; + Koopman = 0xeb31d82e; ) // Table is a 256-word table representing the polynomial for efficient processing. @@ -41,7 +41,7 @@ func MakeTable(poly uint32) *Table { crc := uint32(i); for j := 0; j < 8; j++ { if crc&1 == 1 { - crc = (crc>>1) ^ poly; + crc = (crc>>1)^poly; } else { crc >>= 1; } @@ -52,12 +52,12 @@ func MakeTable(poly uint32) *Table { } // IEEETable is the table for the IEEE polynomial. -var IEEETable = MakeTable(IEEE); +var IEEETable = MakeTable(IEEE) // digest represents the partial evaluation of a checksum. type digest struct { - crc uint32; - tab *Table; + crc uint32; + tab *Table; } // New creates a new Hash computing the CRC-32 checksum @@ -83,7 +83,7 @@ func (d *digest) Reset() { func update(crc uint32, tab *Table, p []byte) uint32 { crc = ^crc; for i := 0; i < len(p); i++ { - crc = tab[byte(crc) ^ p[i]] ^ (crc >> 8); + crc = tab[byte(crc)^p[i]]^(crc>>8); } return ^crc; } @@ -94,7 +94,7 @@ func (d *digest) Write(p []byte) (n int, err os.Error) { } func (d *digest) Sum32() uint32 { - return d.crc + return d.crc; } func (d *digest) Sum() []byte { diff --git a/src/pkg/hash/crc32/crc32_test.go b/src/pkg/hash/crc32/crc32_test.go index 687389894..f42530e7b 100644 --- a/src/pkg/hash/crc32/crc32_test.go +++ b/src/pkg/hash/crc32/crc32_test.go @@ -10,42 +10,42 @@ import ( ) type _Crc32Test struct { - out uint32; - in string; + out uint32; + in string; } -var golden = []_Crc32Test { - _Crc32Test{ 0x0, "" }, - _Crc32Test{ 0xe8b7be43, "a" }, - _Crc32Test{ 0x9e83486d, "ab" }, - _Crc32Test{ 0x352441c2, "abc" }, - _Crc32Test{ 0xed82cd11, "abcd" }, - _Crc32Test{ 0x8587d865, "abcde" }, - _Crc32Test{ 0x4b8e39ef, "abcdef" }, - _Crc32Test{ 0x312a6aa6, "abcdefg" }, - _Crc32Test{ 0xaeef2a50, "abcdefgh" }, - _Crc32Test{ 0x8da988af, "abcdefghi" }, - _Crc32Test{ 0x3981703a, "abcdefghij" }, - _Crc32Test{ 0x6b9cdfe7, "Discard medicine more than two years old." }, - _Crc32Test{ 0xc90ef73f, "He who has a shady past knows that nice guys finish last." }, - _Crc32Test{ 0xb902341f, "I wouldn't marry him with a ten foot pole." }, - _Crc32Test{ 0x42080e8, "Free! Free!/A trip/to Mars/for 900/empty jars/Burma Shave" }, - _Crc32Test{ 0x154c6d11, "The days of the digital watch are numbered. -Tom Stoppard" }, - _Crc32Test{ 0x4c418325, "Nepal premier won't resign." }, - _Crc32Test{ 0x33955150, "For every action there is an equal and opposite government program." }, - _Crc32Test{ 0x26216a4b, "His money is twice tainted: 'taint yours and 'taint mine." }, - _Crc32Test{ 0x1abbe45e, "There is no reason for any individual to have a computer in their home. -Ken Olsen, 1977" }, - _Crc32Test{ 0xc89a94f7, "It's a tiny change to the code and not completely disgusting. - Bob Manchek" }, - _Crc32Test{ 0xab3abe14, "size: a.out: bad magic" }, - _Crc32Test{ 0xbab102b6, "The major problem is with sendmail. -Mark Horton" }, - _Crc32Test{ 0x999149d7, "Give me a rock, paper and scissors and I will move the world. CCFestoon" }, - _Crc32Test{ 0x6d52a33c, "If the enemy is within range, then so are you." }, - _Crc32Test{ 0x90631e8d, "It's well we cannot hear the screams/That we create in others' dreams." }, - _Crc32Test{ 0x78309130, "You remind me of a TV show, but that's all right: I watch it anyway." }, - _Crc32Test{ 0x7d0a377f, "C is as portable as Stonehedge!!" }, - _Crc32Test{ 0x8c79fd79, "Even if I could be Shakespeare, I think I should still choose to be Faraday. - A. Huxley" }, - _Crc32Test{ 0xa20b7167, "The fugacity of a constituent in a mixture of gases at a given temperature is proportional to its mole fraction. Lewis-Randall Rule" }, - _Crc32Test{ 0x8e0bb443, "How can you write a big system without C++? -Paul Glick" }, +var golden = []_Crc32Test{ + _Crc32Test{0x0, ""}, + _Crc32Test{0xe8b7be43, "a"}, + _Crc32Test{0x9e83486d, "ab"}, + _Crc32Test{0x352441c2, "abc"}, + _Crc32Test{0xed82cd11, "abcd"}, + _Crc32Test{0x8587d865, "abcde"}, + _Crc32Test{0x4b8e39ef, "abcdef"}, + _Crc32Test{0x312a6aa6, "abcdefg"}, + _Crc32Test{0xaeef2a50, "abcdefgh"}, + _Crc32Test{0x8da988af, "abcdefghi"}, + _Crc32Test{0x3981703a, "abcdefghij"}, + _Crc32Test{0x6b9cdfe7, "Discard medicine more than two years old."}, + _Crc32Test{0xc90ef73f, "He who has a shady past knows that nice guys finish last."}, + _Crc32Test{0xb902341f, "I wouldn't marry him with a ten foot pole."}, + _Crc32Test{0x42080e8, "Free! Free!/A trip/to Mars/for 900/empty jars/Burma Shave"}, + _Crc32Test{0x154c6d11, "The days of the digital watch are numbered. -Tom Stoppard"}, + _Crc32Test{0x4c418325, "Nepal premier won't resign."}, + _Crc32Test{0x33955150, "For every action there is an equal and opposite government program."}, + _Crc32Test{0x26216a4b, "His money is twice tainted: 'taint yours and 'taint mine."}, + _Crc32Test{0x1abbe45e, "There is no reason for any individual to have a computer in their home. -Ken Olsen, 1977"}, + _Crc32Test{0xc89a94f7, "It's a tiny change to the code and not completely disgusting. - Bob Manchek"}, + _Crc32Test{0xab3abe14, "size: a.out: bad magic"}, + _Crc32Test{0xbab102b6, "The major problem is with sendmail. -Mark Horton"}, + _Crc32Test{0x999149d7, "Give me a rock, paper and scissors and I will move the world. CCFestoon"}, + _Crc32Test{0x6d52a33c, "If the enemy is within range, then so are you."}, + _Crc32Test{0x90631e8d, "It's well we cannot hear the screams/That we create in others' dreams."}, + _Crc32Test{0x78309130, "You remind me of a TV show, but that's all right: I watch it anyway."}, + _Crc32Test{0x7d0a377f, "C is as portable as Stonehedge!!"}, + _Crc32Test{0x8c79fd79, "Even if I could be Shakespeare, I think I should still choose to be Faraday. - A. Huxley"}, + _Crc32Test{0xa20b7167, "The fugacity of a constituent in a mixture of gases at a given temperature is proportional to its mole fraction. Lewis-Randall Rule"}, + _Crc32Test{0x8e0bb443, "How can you write a big system without C++? -Paul Glick"}, } func TestGolden(t *testing.T) { @@ -60,4 +60,3 @@ func TestGolden(t *testing.T) { } } } - diff --git a/src/pkg/hash/hash.go b/src/pkg/hash/hash.go index a7c08cfed..62ec13ba8 100644 --- a/src/pkg/hash/hash.go +++ b/src/pkg/hash/hash.go @@ -4,7 +4,7 @@ package hash -import "io"; +import "io" // Hash is the common interface implemented by all hash functions. // The Write method never returns an error. @@ -21,4 +21,3 @@ type Hash32 interface { Hash; Sum32() uint32; } - |