Commit ca6a0fee authored by Russ Cox's avatar Russ Cox

more "declared and not used".

the last round omitted := range and only
checked 1 out of N vars in a multi-var :=

R=r
OCL=34624
CL=34638
parent 1a319890
...@@ -147,7 +147,7 @@ func TestPartialRead(t *testing.T) { ...@@ -147,7 +147,7 @@ func TestPartialRead(t *testing.T) {
t.Fatalf("Didn't get first file: %v", err); t.Fatalf("Didn't get first file: %v", err);
} }
buf := make([]byte, 4); buf := make([]byte, 4);
if n, err := io.ReadFull(tr, buf); err != nil { if _, err := io.ReadFull(tr, buf); err != nil {
t.Fatalf("Unexpected error: %v", err); t.Fatalf("Unexpected error: %v", err);
} }
if expected := strings.Bytes("Kilt"); !bytes.Equal(buf, expected) { if expected := strings.Bytes("Kilt"); !bytes.Equal(buf, expected) {
...@@ -160,7 +160,7 @@ func TestPartialRead(t *testing.T) { ...@@ -160,7 +160,7 @@ func TestPartialRead(t *testing.T) {
t.Fatalf("Didn't get second file: %v", err); t.Fatalf("Didn't get second file: %v", err);
} }
buf = make([]byte, 6); buf = make([]byte, 6);
if n, err := io.ReadFull(tr, buf); err != nil { if _, err := io.ReadFull(tr, buf); err != nil {
t.Fatalf("Unexpected error: %v", err); t.Fatalf("Unexpected error: %v", err);
} }
if expected := strings.Bytes("Google"); !bytes.Equal(buf, expected) { if expected := strings.Bytes("Google"); !bytes.Equal(buf, expected) {
......
...@@ -64,7 +64,7 @@ var writerTests = []*writerTest{ ...@@ -64,7 +64,7 @@ var writerTests = []*writerTest{
func bytestr(offset int, b []byte) string { func bytestr(offset int, b []byte) string {
const rowLen = 32; const rowLen = 32;
s := fmt.Sprintf("%04x ", offset); s := fmt.Sprintf("%04x ", offset);
for i, ch := range b { for _, ch := range b {
switch { switch {
case '0' <= ch && ch <= '9', 'A' <= ch && ch <= 'Z', 'a' <= ch && ch <= 'z': case '0' <= ch && ch <= '9', 'A' <= ch && ch <= 'Z', 'a' <= ch && ch <= 'z':
s += fmt.Sprintf(" %c", ch); s += fmt.Sprintf(" %c", ch);
...@@ -114,7 +114,7 @@ testLoop: ...@@ -114,7 +114,7 @@ testLoop:
t.Errorf("test %d, entry %d: Failed writing header: %v", i, j, err); t.Errorf("test %d, entry %d: Failed writing header: %v", i, j, err);
continue testLoop continue testLoop
} }
if n, err := io.WriteString(tw, entry.contents); err != nil { if _, err := io.WriteString(tw, entry.contents); err != nil {
t.Errorf("test %d, entry %d: Failed writing contents: %v", i, j, err); t.Errorf("test %d, entry %d: Failed writing contents: %v", i, j, err);
continue testLoop continue testLoop
} }
......
...@@ -158,7 +158,7 @@ func TestDecodeCorrupt(t *testing.T) { ...@@ -158,7 +158,7 @@ func TestDecodeCorrupt(t *testing.T) {
for _, e := range examples { for _, e := range examples {
dbuf := make([]byte, StdEncoding.DecodedLen(len(e.e))); dbuf := make([]byte, StdEncoding.DecodedLen(len(e.e)));
count, err := StdEncoding.Decode(strings.Bytes(e.e), dbuf); _, err := StdEncoding.Decode(strings.Bytes(e.e), dbuf);
switch err := err.(type) { switch err := err.(type) {
case CorruptInputError: case CorruptInputError:
testEqual(t, "Corruption in %q at offset %v, want %v", e.e, int(err), e.p); testEqual(t, "Corruption in %q at offset %v, want %v", e.e, int(err), e.p);
......
...@@ -591,7 +591,7 @@ func divmod(x, y []digit2) ([]digit2, []digit2) { ...@@ -591,7 +591,7 @@ func divmod(x, y []digit2) ([]digit2, []digit2) {
// If y == 0, a division-by-zero run-time error occurs. // If y == 0, a division-by-zero run-time error occurs.
// //
func (x Natural) Div(y Natural) Natural { func (x Natural) Div(y Natural) Natural {
q, r := divmod(unpack(x), unpack(y)); q, _ := divmod(unpack(x), unpack(y));
return pack(q); return pack(q);
} }
...@@ -601,7 +601,7 @@ func (x Natural) Div(y Natural) Natural { ...@@ -601,7 +601,7 @@ func (x Natural) Div(y Natural) Natural {
// If y == 0, a division-by-zero run-time error occurs. // If y == 0, a division-by-zero run-time error occurs.
// //
func (x Natural) Mod(y Natural) Natural { func (x Natural) Mod(y Natural) Natural {
q, r := divmod(unpack(x), unpack(y)); _, r := divmod(unpack(x), unpack(y));
return pack(r); return pack(r);
} }
......
...@@ -152,7 +152,7 @@ func TestNatConv(t *testing.T) { ...@@ -152,7 +152,7 @@ func TestNatConv(t *testing.T) {
test_msg = "NatConvG"; test_msg = "NatConvG";
x := Nat(100); x := Nat(100);
y, b, _ := NatFromString(fmt.Sprintf("%b", &x), 2); y, _, _ := NatFromString(fmt.Sprintf("%b", &x), 2);
nat_eq(100, y, x); nat_eq(100, y, x);
} }
......
...@@ -156,7 +156,7 @@ func TestReader(t *testing.T) { ...@@ -156,7 +156,7 @@ func TestReader(t *testing.T) {
bufreader := bufreaders[j]; bufreader := bufreaders[j];
bufsize := bufsizes[k]; bufsize := bufsizes[k];
read := readmaker.fn(bytes.NewBuffer(textbytes)); read := readmaker.fn(bytes.NewBuffer(textbytes));
buf, e := NewReaderSize(read, bufsize); buf, _ := NewReaderSize(read, bufsize);
s := bufreader.fn(buf); s := bufreader.fn(buf);
if s != text { if s != text {
t.Errorf("reader=%s fn=%s bufsize=%d want=%q got=%q", t.Errorf("reader=%s fn=%s bufsize=%d want=%q got=%q",
...@@ -193,7 +193,7 @@ func readRuneSegments(t *testing.T, segments []string) { ...@@ -193,7 +193,7 @@ func readRuneSegments(t *testing.T, segments []string) {
want := strings.Join(segments, ""); want := strings.Join(segments, "");
r := NewReader(&StringReader{data: segments}); r := NewReader(&StringReader{data: segments});
for { for {
rune, size, err := r.ReadRune(); rune, _, err := r.ReadRune();
if err != nil { if err != nil {
if err != os.EOF { if err != os.EOF {
return; return;
...@@ -293,9 +293,9 @@ var errorWriterTests = []errorWriterTest { ...@@ -293,9 +293,9 @@ var errorWriterTests = []errorWriterTest {
} }
func TestWriteErrors(t *testing.T) { func TestWriteErrors(t *testing.T) {
for i, w := range errorWriterTests { for _, w := range errorWriterTests {
buf := NewWriter(w); buf := NewWriter(w);
n, e := buf.Write(strings.Bytes("hello world")); _, e := buf.Write(strings.Bytes("hello world"));
if e != nil { if e != nil {
t.Errorf("Write hello to %v: %v", w, e); t.Errorf("Write hello to %v: %v", w, e);
continue; continue;
......
...@@ -164,7 +164,7 @@ func TestMixedReadsAndWrites(t *testing.T) { ...@@ -164,7 +164,7 @@ func TestMixedReadsAndWrites(t *testing.T) {
rlen := rand.Intn(len(data)); rlen := rand.Intn(len(data));
fub := make([]byte, rlen); fub := make([]byte, rlen);
n, err := buf.Read(fub); n, _ := buf.Read(fub);
s = s[n : len(s)]; s = s[n : len(s)];
} }
empty(t, "TestMixedReadsAndWrites (2)", &buf, s, make([]byte, buf.Len())); empty(t, "TestMixedReadsAndWrites (2)", &buf, s, make([]byte, buf.Len()));
......
...@@ -190,8 +190,8 @@ func Map(mapping func(rune int) int, s []byte) []byte { ...@@ -190,8 +190,8 @@ func Map(mapping func(rune int) int, s []byte) []byte {
maxbytes := len(s); // length of b maxbytes := len(s); // length of b
nbytes := 0; // number of bytes encoded in b nbytes := 0; // number of bytes encoded in b
b := make([]byte, maxbytes); b := make([]byte, maxbytes);
for wid, i := 0, 0; i < len(s); i += wid { for i := 0; i < len(s); {
wid = 1; wid := 1;
rune := int(s[i]); rune := int(s[i]);
if rune < utf8.RuneSelf { if rune < utf8.RuneSelf {
rune = mapping(rune); rune = mapping(rune);
...@@ -209,6 +209,7 @@ func Map(mapping func(rune int) int, s []byte) []byte { ...@@ -209,6 +209,7 @@ func Map(mapping func(rune int) int, s []byte) []byte {
b = nb; b = nb;
} }
nbytes += utf8.EncodeRune(rune, b[nbytes:maxbytes]); nbytes += utf8.EncodeRune(rune, b[nbytes:maxbytes]);
i += wid;
} }
return b[0:nbytes]; return b[0:nbytes];
} }
...@@ -232,8 +233,8 @@ func Title(s []byte) []byte { ...@@ -232,8 +233,8 @@ func Title(s []byte) []byte {
// removed, as defined by Unicode. // removed, as defined by Unicode.
func TrimSpace(s []byte) []byte { func TrimSpace(s []byte) []byte {
start, end := 0, len(s); start, end := 0, len(s);
for wid := 0; start < end; start += wid { for start < end {
wid = 1; wid := 1;
rune := int(s[start]); rune := int(s[start]);
if rune >= utf8.RuneSelf { if rune >= utf8.RuneSelf {
rune, wid = utf8.DecodeRune(s[start:end]) rune, wid = utf8.DecodeRune(s[start:end])
...@@ -241,9 +242,10 @@ func TrimSpace(s []byte) []byte { ...@@ -241,9 +242,10 @@ func TrimSpace(s []byte) []byte {
if !unicode.IsSpace(rune) { if !unicode.IsSpace(rune) {
break; break;
} }
start += wid;
} }
for wid := 0; start < end; end -= wid { for start < end {
wid = 1; wid := 1;
rune := int(s[end-1]); rune := int(s[end-1]);
if rune >= utf8.RuneSelf { if rune >= utf8.RuneSelf {
// Back up carefully looking for beginning of rune. Mustn't pass start. // Back up carefully looking for beginning of rune. Mustn't pass start.
...@@ -257,6 +259,7 @@ func TrimSpace(s []byte) []byte { ...@@ -257,6 +259,7 @@ func TrimSpace(s []byte) []byte {
if !unicode.IsSpace(rune) { if !unicode.IsSpace(rune) {
break; break;
} }
end -= wid;
} }
return s[start:end]; return s[start:end];
} }
......
...@@ -216,7 +216,7 @@ func Bytes(s string) []byte { ...@@ -216,7 +216,7 @@ func Bytes(s string) []byte {
// Execute f on each test case. funcName should be the name of f; it's used // Execute f on each test case. funcName should be the name of f; it's used
// in failure reports. // in failure reports.
func runStringTests(t *testing.T, f func([]byte) []byte, funcName string, testCases []StringTest) { func runStringTests(t *testing.T, f func([]byte) []byte, funcName string, testCases []StringTest) {
for i, tc := range testCases { for _, tc := range testCases {
actual := string(f(Bytes(tc.in))); actual := string(f(Bytes(tc.in)));
if actual != tc.out { if actual != tc.out {
t.Errorf("%s(%q) = %q; want %q", funcName, tc.in, actual, tc.out); t.Errorf("%s(%q) = %q; want %q", funcName, tc.in, actual, tc.out);
...@@ -275,7 +275,7 @@ var addtests = []AddTest { ...@@ -275,7 +275,7 @@ var addtests = []AddTest {
} }
func TestAdd(t *testing.T) { func TestAdd(t *testing.T) {
for i, test := range addtests { for _, test := range addtests {
b := make([]byte, len(test.s), test.cap); b := make([]byte, len(test.s), test.cap);
for i := 0; i < len(test.s); i++ { for i := 0; i < len(test.s); i++ {
b[i] = test.s[i] b[i] = test.s[i]
......
...@@ -121,7 +121,7 @@ func (h *huffmanDecoder) init(bits []int) bool { ...@@ -121,7 +121,7 @@ func (h *huffmanDecoder) init(bits []int) bool {
// compute min and max length. // compute min and max length.
var count [maxCodeLen+1]int; var count [maxCodeLen+1]int;
var min, max int; var min, max int;
for i, n := range bits { for _, n := range bits {
if n == 0 { if n == 0 {
continue; continue;
} }
......
...@@ -116,7 +116,7 @@ func (z *Inflater) read2() (uint32, os.Error) { ...@@ -116,7 +116,7 @@ func (z *Inflater) read2() (uint32, os.Error) {
} }
func (z *Inflater) readHeader(save bool) os.Error { func (z *Inflater) readHeader(save bool) os.Error {
n, err := io.ReadFull(z.r, z.buf[0:10]); _, err := io.ReadFull(z.r, z.buf[0:10]);
if err != nil { if err != nil {
return err; return err;
} }
......
...@@ -282,7 +282,7 @@ var gzipTests = []gzipTest { ...@@ -282,7 +282,7 @@ var gzipTests = []gzipTest {
func TestInflater(t *testing.T) { func TestInflater(t *testing.T) {
b := new(bytes.Buffer); b := new(bytes.Buffer);
for i, tt := range gzipTests { for _, tt := range gzipTests {
in := bytes.NewBuffer(tt.gzip); in := bytes.NewBuffer(tt.gzip);
gzip, err := NewInflater(in); gzip, err := NewInflater(in);
if err != nil { if err != nil {
......
...@@ -39,7 +39,7 @@ func NewInflater(r io.Reader) (io.ReadCloser, os.Error) { ...@@ -39,7 +39,7 @@ func NewInflater(r io.Reader) (io.ReadCloser, os.Error) {
} else { } else {
z.r = bufio.NewReader(r); z.r = bufio.NewReader(r);
} }
n, err := io.ReadFull(z.r, z.scratch[0:2]); _, err := io.ReadFull(z.r, z.scratch[0:2]);
if err != nil { if err != nil {
return nil, err; return nil, err;
} }
......
...@@ -77,7 +77,7 @@ var zlibTests = []zlibTest { ...@@ -77,7 +77,7 @@ var zlibTests = []zlibTest {
func TestInflater(t *testing.T) { func TestInflater(t *testing.T) {
b := new(bytes.Buffer); b := new(bytes.Buffer);
for i, tt := range zlibTests { for _, tt := range zlibTests {
in := bytes.NewBuffer(tt.compressed); in := bytes.NewBuffer(tt.compressed);
zlib, err := NewInflater(in); zlib, err := NewInflater(in);
if err != nil { if err != nil {
......
...@@ -102,7 +102,7 @@ func (p *IntVector) Less(i, j int) bool { ...@@ -102,7 +102,7 @@ func (p *IntVector) Less(i, j int) bool {
// Iterate over all elements; driver for range // Iterate over all elements; driver for range
func (p *IntVector) iterate(c chan<- int) { func (p *IntVector) iterate(c chan<- int) {
for i, v := range p.a { for _, v := range p.a {
c <- v.(int) c <- v.(int)
} }
close(c); close(c);
......
...@@ -101,7 +101,7 @@ func (p *StringVector) Less(i, j int) bool { ...@@ -101,7 +101,7 @@ func (p *StringVector) Less(i, j int) bool {
// Iterate over all elements; driver for range // Iterate over all elements; driver for range
func (p *StringVector) iterate(c chan<- string) { func (p *StringVector) iterate(c chan<- string) {
for i, v := range p.a { for _, v := range p.a {
c <- v.(string) c <- v.(string)
} }
close(c); close(c);
......
...@@ -230,7 +230,7 @@ func (p *Vector) Swap(i, j int) { ...@@ -230,7 +230,7 @@ func (p *Vector) Swap(i, j int) {
// Iterate over all elements; driver for range // Iterate over all elements; driver for range
func (p *Vector) iterate(c chan<- Element) { func (p *Vector) iterate(c chan<- Element) {
for i, v := range p.a { for _, v := range p.a {
c <- v c <- v
} }
close(c); close(c);
......
...@@ -67,7 +67,7 @@ var cbcAESTests = []cbcTest { ...@@ -67,7 +67,7 @@ var cbcAESTests = []cbcTest {
} }
func TestCBC_AES(t *testing.T) { func TestCBC_AES(t *testing.T) {
for i, tt := range cbcAESTests { for _, tt := range cbcAESTests {
test := tt.name; test := tt.name;
c, err := aes.NewCipher(tt.key); c, err := aes.NewCipher(tt.key);
......
...@@ -271,7 +271,7 @@ var cfbAESTests = []cfbTest { ...@@ -271,7 +271,7 @@ var cfbAESTests = []cfbTest {
} }
func TestCFB_AES(t *testing.T) { func TestCFB_AES(t *testing.T) {
for i, tt := range cfbAESTests { for _, tt := range cfbAESTests {
test := tt.name; test := tt.name;
if tt.s == 1 { if tt.s == 1 {
......
...@@ -70,7 +70,7 @@ func (d *cmac) Reset() { ...@@ -70,7 +70,7 @@ func (d *cmac) Reset() {
// Write adds the given data to the digest state. // Write adds the given data to the digest state.
func (d *cmac) Write(p []byte) (n int, err os.Error) { func (d *cmac) Write(p []byte) (n int, err os.Error) {
// Xor input into ci. // Xor input into ci.
for i, c := range p { for _, c := range p {
// If ci is full, encrypt and start over. // If ci is full, encrypt and start over.
if d.p >= len(d.ci) { if d.p >= len(d.ci) {
d.c.Encrypt(d.ci, d.ci); d.c.Encrypt(d.ci, d.ci);
......
...@@ -71,7 +71,7 @@ var ctrAESTests = []ctrTest { ...@@ -71,7 +71,7 @@ var ctrAESTests = []ctrTest {
} }
func TestCTR_AES(t *testing.T) { func TestCTR_AES(t *testing.T) {
for i, tt := range ctrAESTests { for _, tt := range ctrAESTests {
test := tt.name; test := tt.name;
c, err := aes.NewCipher(tt.key); c, err := aes.NewCipher(tt.key);
......
...@@ -127,7 +127,7 @@ func (x *ecbDecrypter) Read(p []byte) (n int, err os.Error) { ...@@ -127,7 +127,7 @@ func (x *ecbDecrypter) Read(p []byte) (n int, err os.Error) {
if i < n { if i < n {
p = p[i:n]; p = p[i:n];
for j, v := range p { for j, v := range p {
x.buf[j] = p[j]; x.buf[j] = v;
} }
x.crypt = x.buf[0:len(p)]; x.crypt = x.buf[0:len(p)];
n = i; n = i;
......
...@@ -100,7 +100,7 @@ var ecbAESTests = []ecbTest { ...@@ -100,7 +100,7 @@ var ecbAESTests = []ecbTest {
} }
func TestECB_AES(t *testing.T) { func TestECB_AES(t *testing.T) {
for i, tt := range ecbAESTests { for _, tt := range ecbAESTests {
test := tt.name; test := tt.name;
c, err := aes.NewCipher(tt.key); c, err := aes.NewCipher(tt.key);
......
...@@ -75,20 +75,20 @@ func TestECBEncrypter(t *testing.T) { ...@@ -75,20 +75,20 @@ func TestECBEncrypter(t *testing.T) {
// copy plain into w in increasingly large chunks: 1, 1, 2, 4, 8, ... // copy plain into w in increasingly large chunks: 1, 1, 2, 4, 8, ...
// if frag != 0, move the 1 to the end to cause fragmentation. // if frag != 0, move the 1 to the end to cause fragmentation.
if frag == 0 { if frag == 0 {
nn, err := io.Copyn(r, w, 1); _, err := io.Copyn(r, w, 1);
if err != nil { if err != nil {
t.Errorf("block=%d frag=0: first Copyn: %s", block, err); t.Errorf("block=%d frag=0: first Copyn: %s", block, err);
continue; continue;
} }
} }
for n := 1; n <= len(plain)/2; n *= 2 { for n := 1; n <= len(plain)/2; n *= 2 {
nn, err := io.Copyn(r, w, int64(n)); _, err := io.Copyn(r, w, int64(n));
if err != nil { if err != nil {
t.Errorf("block=%d frag=%d: Copyn %d: %s", block, frag, n, err); t.Errorf("block=%d frag=%d: Copyn %d: %s", block, frag, n, err);
} }
} }
if frag != 0 { if frag != 0 {
nn, err := io.Copyn(r, w, 1); _, err := io.Copyn(r, w, 1);
if err != nil { if err != nil {
t.Errorf("block=%d frag=1: last Copyn: %s", block, err); t.Errorf("block=%d frag=1: last Copyn: %s", block, err);
continue; continue;
...@@ -140,20 +140,20 @@ func testECBDecrypter(t *testing.T, maxio int) { ...@@ -140,20 +140,20 @@ func testECBDecrypter(t *testing.T, maxio int) {
// read from crypt in increasingly large chunks: 1, 1, 2, 4, 8, ... // read from crypt in increasingly large chunks: 1, 1, 2, 4, 8, ...
// if frag == 1, move the 1 to the end to cause fragmentation. // if frag == 1, move the 1 to the end to cause fragmentation.
if frag == 0 { if frag == 0 {
nn, err := io.Copyn(r, b, 1); _, err := io.Copyn(r, b, 1);
if err != nil { if err != nil {
t.Errorf("%s: first Copyn: %s", test, err); t.Errorf("%s: first Copyn: %s", test, err);
continue; continue;
} }
} }
for n := 1; n <= maxio/2; n *= 2 { for n := 1; n <= maxio/2; n *= 2 {
nn, err := io.Copyn(r, b, int64(n)); _, err := io.Copyn(r, b, int64(n));
if err != nil { if err != nil {
t.Errorf("%s: Copyn %d: %s", test, n, err); t.Errorf("%s: Copyn %d: %s", test, n, err);
} }
} }
if frag != 0 { if frag != 0 {
nn, err := io.Copyn(r, b, 1); _, err := io.Copyn(r, b, 1);
if err != nil { if err != nil {
t.Errorf("%s: last Copyn: %s", test, err); t.Errorf("%s: last Copyn: %s", test, err);
continue; continue;
......
...@@ -67,7 +67,7 @@ var ofbAESTests = []ofbTest { ...@@ -67,7 +67,7 @@ var ofbAESTests = []ofbTest {
} }
func TestOFB_AES(t *testing.T) { func TestOFB_AES(t *testing.T) {
for i, tt := range ofbAESTests { for _, tt := range ofbAESTests {
test := tt.name; test := tt.name;
c, err := aes.NewCipher(tt.key); c, err := aes.NewCipher(tt.key);
......
...@@ -60,14 +60,14 @@ func testXorWriter(t *testing.T, maxio int) { ...@@ -60,14 +60,14 @@ func testXorWriter(t *testing.T, maxio int) {
// copy plain into w in increasingly large chunks: 1, 1, 2, 4, 8, ... // copy plain into w in increasingly large chunks: 1, 1, 2, 4, 8, ...
// if frag != 0, move the 1 to the end to cause fragmentation. // if frag != 0, move the 1 to the end to cause fragmentation.
if frag == 0 { if frag == 0 {
nn, err := io.Copyn(r, w, 1); _, err := io.Copyn(r, w, 1);
if err != nil { if err != nil {
t.Errorf("%s: first Copyn: %s", test, err); t.Errorf("%s: first Copyn: %s", test, err);
continue; continue;
} }
} }
for n := 1; n <= len(plain)/2; n *= 2 { for n := 1; n <= len(plain)/2; n *= 2 {
nn, err := io.Copyn(r, w, int64(n)); _, err := io.Copyn(r, w, int64(n));
if err != nil { if err != nil {
t.Errorf("%s: Copyn %d: %s", test, n, err); t.Errorf("%s: Copyn %d: %s", test, n, err);
} }
...@@ -128,14 +128,14 @@ func testXorReader(t *testing.T, maxio int) { ...@@ -128,14 +128,14 @@ func testXorReader(t *testing.T, maxio int) {
// read from crypt in increasingly large chunks: 1, 1, 2, 4, 8, ... // read from crypt in increasingly large chunks: 1, 1, 2, 4, 8, ...
// if frag == 1, move the 1 to the end to cause fragmentation. // if frag == 1, move the 1 to the end to cause fragmentation.
if frag == 0 { if frag == 0 {
nn, err := io.Copyn(r, b, 1); _, err := io.Copyn(r, b, 1);
if err != nil { if err != nil {
t.Errorf("%s: first Copyn: %s", test, err); t.Errorf("%s: first Copyn: %s", test, err);
continue; continue;
} }
} }
for n := 1; n <= maxio/2; n *= 2 { for n := 1; n <= maxio/2; n *= 2 {
nn, err := io.Copyn(r, b, int64(n)); _, err := io.Copyn(r, b, int64(n));
if err != nil { if err != nil {
t.Errorf("%s: Copyn %d: %s", test, n, err); t.Errorf("%s: Copyn %d: %s", test, n, err);
} }
......
...@@ -728,7 +728,7 @@ func (f Format) Print(args ...) (int, os.Error) { ...@@ -728,7 +728,7 @@ func (f Format) Print(args ...) (int, os.Error) {
// //
func (f Format) Sprint(args ...) string { func (f Format) Sprint(args ...) string {
var buf bytes.Buffer; var buf bytes.Buffer;
n, err := f.Fprint(&buf, nil, args); _, err := f.Fprint(&buf, nil, args);
if err != nil { if err != nil {
fmt.Fprintf(&buf, "--- Sprint(%s) failed: %v", fmt.Sprint(args), err); fmt.Fprintf(&buf, "--- Sprint(%s) failed: %v", fmt.Sprint(args), err);
} }
......
...@@ -368,7 +368,7 @@ func Parse(filename string, src []byte, fmap FormatterMap) (Format, os.Error) { ...@@ -368,7 +368,7 @@ func Parse(filename string, src []byte, fmap FormatterMap) (Format, os.Error) {
// add custom formatters, if any // add custom formatters, if any
for name, form := range fmap { for name, form := range fmap {
name = remap(&p, name); name = remap(&p, name);
if t, found := p.rules[name]; !found { if _, found := p.rules[name]; !found {
p.rules[name] = &custom{name, form}; p.rules[name] = &custom{name, form};
} else { } else {
var invalidPos token.Position; var invalidPos token.Position;
......
...@@ -89,7 +89,7 @@ func Read(r io.Reader, order ByteOrder, data interface{}) os.Error { ...@@ -89,7 +89,7 @@ func Read(r io.Reader, order ByteOrder, data interface{}) os.Error {
return os.NewError("binary.Read: invalid type " + v.Type().String()); return os.NewError("binary.Read: invalid type " + v.Type().String());
} }
d := &decoder{order: order, buf: make([]byte, size)}; d := &decoder{order: order, buf: make([]byte, size)};
if n, err := io.ReadFull(r, d.buf); err != nil { if _, err := io.ReadFull(r, d.buf); err != nil {
return err; return err;
} }
d.value(v); d.value(v);
......
...@@ -63,12 +63,12 @@ func (t *LineTable) slice(pc uint64) *LineTable { ...@@ -63,12 +63,12 @@ func (t *LineTable) slice(pc uint64) *LineTable {
} }
func (t *LineTable) PCToLine(pc uint64) int { func (t *LineTable) PCToLine(pc uint64) int {
b, pc, line := t.parse(pc, -1); _, _, line := t.parse(pc, -1);
return line; return line;
} }
func (t *LineTable) LineToPC(line int, maxpc uint64) uint64 { func (t *LineTable) LineToPC(line int, maxpc uint64) uint64 {
b, pc, line1 := t.parse(maxpc, line); _, pc, line1 := t.parse(maxpc, line);
if line1 != line { if line1 != line {
return 0; return 0;
} }
......
...@@ -123,7 +123,7 @@ func (p *Production) Pos() token.Position { ...@@ -123,7 +123,7 @@ func (p *Production) Pos() token.Position {
// Grammar verification // Grammar verification
func isLexical(name string) bool { func isLexical(name string) bool {
ch, len := utf8.DecodeRuneInString(name); ch, _ := utf8.DecodeRuneInString(name);
return !unicode.IsUpper(ch); return !unicode.IsUpper(ch);
} }
......
...@@ -195,7 +195,7 @@ func (p *parser) parse(filename string, src []byte) Grammar { ...@@ -195,7 +195,7 @@ func (p *parser) parse(filename string, src []byte) Grammar {
for p.tok != token.EOF { for p.tok != token.EOF {
prod := p.parseProduction(); prod := p.parseProduction();
name := prod.Name.String; name := prod.Name.String;
if prev, found := grammar[name]; !found { if _, found := grammar[name]; !found {
grammar[name] = prod; grammar[name] = prod;
} else { } else {
p.Error(prod.Pos(), name + " declared already"); p.Error(prod.Pos(), name + " declared already");
......
...@@ -158,9 +158,9 @@ func (p *Cmd) Close() os.Error { ...@@ -158,9 +158,9 @@ func (p *Cmd) Close() os.Error {
// Loop on interrupt, but // Loop on interrupt, but
// ignore other errors -- maybe // ignore other errors -- maybe
// caller has already waited for pid. // caller has already waited for pid.
w, err := p.Wait(0); _, err := p.Wait(0);
for err == os.EINTR { for err == os.EINTR {
w, err = p.Wait(0); _, err = p.Wait(0);
} }
} }
...@@ -209,7 +209,7 @@ func LookPath(file string) (string, os.Error) { ...@@ -209,7 +209,7 @@ func LookPath(file string) (string, os.Error) {
return "", os.ENOENT; return "", os.ENOENT;
} }
pathenv := os.Getenv("PATH"); pathenv := os.Getenv("PATH");
for i, dir := range strings.Split(pathenv, ":", 0) { for _, dir := range strings.Split(pathenv, ":", 0) {
if dir == "" { if dir == "" {
// Unix shell semantics: path element "" means "." // Unix shell semantics: path element "" means "."
dir = "."; dir = ".";
......
...@@ -203,14 +203,14 @@ var flags *allFlags = &allFlags{make(map[string] *Flag), make(map[string] *Flag) ...@@ -203,14 +203,14 @@ var flags *allFlags = &allFlags{make(map[string] *Flag), make(map[string] *Flag)
// VisitAll visits the flags, calling fn for each. It visits all flags, even those not set. // VisitAll visits the flags, calling fn for each. It visits all flags, even those not set.
func VisitAll(fn func(*Flag)) { func VisitAll(fn func(*Flag)) {
for k, f := range flags.formal { for _, f := range flags.formal {
fn(f) fn(f)
} }
} }
// Visit visits the flags, calling fn for each. It visits only those flags that have been set. // Visit visits the flags, calling fn for each. It visits only those flags that have been set.
func Visit(fn func(*Flag)) { func Visit(fn func(*Flag)) {
for k, f := range flags.actual { for _, f := range flags.actual {
fn(f) fn(f)
} }
} }
...@@ -243,7 +243,7 @@ func Set(name, value string) bool { ...@@ -243,7 +243,7 @@ func Set(name, value string) bool {
func PrintDefaults() { func PrintDefaults() {
VisitAll(func(f *Flag) { VisitAll(func(f *Flag) {
format := " -%s=%s: %s\n"; format := " -%s=%s: %s\n";
if s, ok := f.Value.(*stringValue); ok { if _, ok := f.Value.(*stringValue); ok {
// put quotes on the value // put quotes on the value
format = " -%s=%q: %s\n"; format = " -%s=%q: %s\n";
} }
...@@ -285,7 +285,7 @@ func Args() []string { ...@@ -285,7 +285,7 @@ func Args() []string {
func add(name string, value FlagValue, usage string) { func add(name string, value FlagValue, usage string) {
// Remember the default value as a string; it won't change. // Remember the default value as a string; it won't change.
f := &Flag{name, usage, value, value.String()}; f := &Flag{name, usage, value, value.String()};
dummy, alreadythere := flags.formal[name]; _, alreadythere := flags.formal[name];
if alreadythere { if alreadythere {
fmt.Fprintln(os.Stderr, "flag redefined:", name); fmt.Fprintln(os.Stderr, "flag redefined:", name);
panic("flag redefinition"); // Happens only if flags are declared with identical names panic("flag redefinition"); // Happens only if flags are declared with identical names
......
...@@ -194,7 +194,7 @@ var fmttests = []fmtTest{ ...@@ -194,7 +194,7 @@ var fmttests = []fmtTest{
} }
func TestSprintf(t *testing.T) { func TestSprintf(t *testing.T) {
for i, tt := range fmttests { for _, tt := range fmttests {
s := Sprintf(tt.fmt, tt.val); s := Sprintf(tt.fmt, tt.val);
if i := strings.Index(s, "0x"); i >= 0 && strings.Index(tt.out, "PTR") >= 0 { if i := strings.Index(s, "0x"); i >= 0 && strings.Index(tt.out, "PTR") >= 0 {
j := i+2; j := i+2;
...@@ -207,7 +207,7 @@ func TestSprintf(t *testing.T) { ...@@ -207,7 +207,7 @@ func TestSprintf(t *testing.T) {
s = s[0:i] + "PTR" + s[j:len(s)]; s = s[0:i] + "PTR" + s[j:len(s)];
} }
if s != tt.out { if s != tt.out {
if ss, ok := tt.val.(string); ok { if _, ok := tt.val.(string); ok {
// Don't requote the already-quoted strings. // Don't requote the already-quoted strings.
// It's too confusing to read the errors. // It's too confusing to read the errors.
t.Errorf("Sprintf(%q, %q) = %s want %s", tt.fmt, tt.val, s, tt.out); t.Errorf("Sprintf(%q, %q) = %s want %s", tt.fmt, tt.val, s, tt.out);
...@@ -258,7 +258,7 @@ var flagtests = []flagTest { ...@@ -258,7 +258,7 @@ var flagtests = []flagTest {
func TestFlagParser(t *testing.T) { func TestFlagParser(t *testing.T) {
var flagprinter flagPrinter; var flagprinter flagPrinter;
for i, tt := range flagtests { for _, tt := range flagtests {
s := Sprintf(tt.in, &flagprinter); s := Sprintf(tt.in, &flagprinter);
if s != tt.out { if s != tt.out {
t.Errorf("Sprintf(%q, &flagprinter) => %q, want %q", tt.in, s, tt.out); t.Errorf("Sprintf(%q, &flagprinter) => %q, want %q", tt.in, s, tt.out);
...@@ -283,7 +283,7 @@ func TestStructPrinter(t *testing.T) { ...@@ -283,7 +283,7 @@ func TestStructPrinter(t *testing.T) {
Test{ "%v", "{abc def 123}" }, Test{ "%v", "{abc def 123}" },
Test{ "%+v", "{a:abc b:def c:123}" }, Test{ "%+v", "{a:abc b:def c:123}" },
}; };
for i, tt := range tests { for _, tt := range tests {
out := Sprintf(tt.fmt, s); out := Sprintf(tt.fmt, s);
if out != tt.out { if out != tt.out {
t.Errorf("Sprintf(%q, &s) = %q, want %q", tt.fmt, out, tt.out); t.Errorf("Sprintf(%q, &s) = %q, want %q", tt.fmt, out, tt.out);
......
...@@ -680,7 +680,7 @@ func (p *pp) doprintf(format string, v *reflect.StructValue) { ...@@ -680,7 +680,7 @@ func (p *pp) doprintf(format string, v *reflect.StructValue) {
// int // int
case 'b': case 'b':
if v, signed, ok := getInt(field); ok { if v, _, ok := getInt(field); ok {
s = p.fmt.Fmt_b64(uint64(v)).Str() // always unsigned s = p.fmt.Fmt_b64(uint64(v)).Str() // always unsigned
} else if v, ok := getFloat32(field); ok { } else if v, ok := getFloat32(field); ok {
s = p.fmt.Fmt_fb32(v).Str() s = p.fmt.Fmt_fb32(v).Str()
...@@ -690,7 +690,7 @@ func (p *pp) doprintf(format string, v *reflect.StructValue) { ...@@ -690,7 +690,7 @@ func (p *pp) doprintf(format string, v *reflect.StructValue) {
goto badtype goto badtype
} }
case 'c': case 'c':
if v, signed, ok := getInt(field); ok { if v, _, ok := getInt(field); ok {
s = p.fmt.Fmt_c(int(v)).Str() s = p.fmt.Fmt_c(int(v)).Str()
} else { } else {
goto badtype goto badtype
......
...@@ -350,7 +350,7 @@ func (x *ChanType) exprNode() {} ...@@ -350,7 +350,7 @@ func (x *ChanType) exprNode() {}
// IsExported returns whether name is an exported Go symbol // IsExported returns whether name is an exported Go symbol
// (i.e., whether it begins with an uppercase letter). // (i.e., whether it begins with an uppercase letter).
func IsExported(name string) bool { func IsExported(name string) bool {
ch, len := utf8.DecodeRuneInString(name); ch, _ := utf8.DecodeRuneInString(name);
return unicode.IsUpper(ch); return unicode.IsUpper(ch);
} }
......
...@@ -43,13 +43,13 @@ func setupRegexps() { ...@@ -43,13 +43,13 @@ func setupRegexps() {
func commentText(comments []string) string { func commentText(comments []string) string {
once.Do(setupRegexps); once.Do(setupRegexps);
lines := make([]string, 0, 20); lines := make([]string, 0, 20);
for i, c := range comments { for _, c := range comments {
// split on newlines // split on newlines
cl := strings.Split(c, "\n", 0); cl := strings.Split(c, "\n", 0);
// walk lines, stripping comment markers // walk lines, stripping comment markers
w := 0; w := 0;
for j, l := range cl { for _, l := range cl {
// remove /* and */ lines // remove /* and */ lines
if comment_junk.MatchString(l) { if comment_junk.MatchString(l) {
continue; continue;
...@@ -85,7 +85,7 @@ func commentText(comments []string) string { ...@@ -85,7 +85,7 @@ func commentText(comments []string) string {
// add this comment to total list // add this comment to total list
// TODO: maybe separate with a single blank line // TODO: maybe separate with a single blank line
// if there is already a comment and len(cl) > 0? // if there is already a comment and len(cl) > 0?
for j, l := range cl { for _, l := range cl {
n := len(lines); n := len(lines);
if n+1 >= cap(lines) { if n+1 >= cap(lines) {
newlines := make([]string, n, 2*cap(lines)); newlines := make([]string, n, 2*cap(lines));
...@@ -205,7 +205,7 @@ func unindent(block [][]byte) { ...@@ -205,7 +205,7 @@ func unindent(block [][]byte) {
// compute maximum common white prefix // compute maximum common white prefix
prefix := block[0][0 : indentLen(block[0])]; prefix := block[0][0 : indentLen(block[0])];
for i, line := range block { for _, line := range block {
if !isBlank(line) { if !isBlank(line) {
prefix = commonPrefix(prefix, line[0 : indentLen(line)]); prefix = commonPrefix(prefix, line[0 : indentLen(line)]);
} }
...@@ -288,7 +288,7 @@ func ToHtml(w io.Writer, s []byte) { ...@@ -288,7 +288,7 @@ func ToHtml(w io.Writer, s []byte) {
// they don't get the nice text formatting, // they don't get the nice text formatting,
// just html escaping // just html escaping
w.Write(html_pre); w.Write(html_pre);
for k, line := range block { for _, line := range block {
template.HtmlEscape(w, line); template.HtmlEscape(w, line);
} }
w.Write(html_endpre); w.Write(html_endpre);
......
...@@ -563,7 +563,7 @@ func isRegexp(s string) bool { ...@@ -563,7 +563,7 @@ func isRegexp(s string) bool {
func match(s string, a []string) bool { func match(s string, a []string) bool {
for _, t := range a { for _, t := range a {
if isRegexp(t) { if isRegexp(t) {
if matched, err := regexp.MatchString(t, s); matched { if matched, _ := regexp.MatchString(t, s); matched {
return true; return true;
} }
} }
......
...@@ -38,7 +38,7 @@ func readSource(filename string, src interface{}) ([]byte, os.Error) { ...@@ -38,7 +38,7 @@ func readSource(filename string, src interface{}) ([]byte, os.Error) {
} }
case io.Reader: case io.Reader:
var buf bytes.Buffer; var buf bytes.Buffer;
n, err := io.Copy(s, &buf); _, err := io.Copy(s, &buf);
if err != nil { if err != nil {
return nil, err; return nil, err;
} }
......
...@@ -650,7 +650,7 @@ func (p *parser) parseMethodSpec() *ast.Field { ...@@ -650,7 +650,7 @@ func (p *parser) parseMethodSpec() *ast.Field {
var idents []*ast.Ident; var idents []*ast.Ident;
var typ ast.Expr; var typ ast.Expr;
x := p.parseQualifiedIdent(); x := p.parseQualifiedIdent();
if tmp, isIdent := x.(*ast.Ident); isIdent && (p.tok == token.COMMA || p.tok == token.LPAREN) { if _, isIdent := x.(*ast.Ident); isIdent && (p.tok == token.COMMA || p.tok == token.LPAREN) {
// methods // methods
idents = p.parseIdentList(x); idents = p.parseIdentList(x);
params, results := p.parseSignature(); params, results := p.parseSignature();
......
...@@ -21,7 +21,7 @@ var illegalInputs = []interface{} { ...@@ -21,7 +21,7 @@ var illegalInputs = []interface{} {
func TestParseIllegalInputs(t *testing.T) { func TestParseIllegalInputs(t *testing.T) {
for _, src := range illegalInputs { for _, src := range illegalInputs {
prog, err := ParseFile("", src, 0); _, err := ParseFile("", src, 0);
if err == nil { if err == nil {
t.Errorf("ParseFile(%v) should have failed", src); t.Errorf("ParseFile(%v) should have failed", src);
} }
...@@ -37,7 +37,7 @@ var validPrograms = []interface{} { ...@@ -37,7 +37,7 @@ var validPrograms = []interface{} {
func TestParseValidPrograms(t *testing.T) { func TestParseValidPrograms(t *testing.T) {
for _, src := range validPrograms { for _, src := range validPrograms {
prog, err := ParseFile("", src, 0); _, err := ParseFile("", src, 0);
if err != nil { if err != nil {
t.Errorf("ParseFile(%q): %v", src, err); t.Errorf("ParseFile(%q): %v", src, err);
} }
...@@ -53,7 +53,7 @@ var validFiles = []string { ...@@ -53,7 +53,7 @@ var validFiles = []string {
func TestParse3(t *testing.T) { func TestParse3(t *testing.T) {
for _, filename := range validFiles { for _, filename := range validFiles {
prog, err := ParseFile(filename, nil, 0); _, err := ParseFile(filename, nil, 0);
if err != nil { if err != nil {
t.Errorf("ParseFile(%s): %v", filename, err); t.Errorf("ParseFile(%s): %v", filename, err);
} }
......
...@@ -847,7 +847,7 @@ func (p *printer) block(s *ast.BlockStmt) { ...@@ -847,7 +847,7 @@ func (p *printer) block(s *ast.BlockStmt) {
func (p *printer) switchBlock(s *ast.BlockStmt) { func (p *printer) switchBlock(s *ast.BlockStmt) {
p.print(s.Pos(), token.LBRACE); p.print(s.Pos(), token.LBRACE);
if len(s.List) > 0 { if len(s.List) > 0 {
for i, s := range s.List { for _, s := range s.List {
// s is one of *ast.CaseClause, *ast.TypeCaseClause, *ast.CommClause; // s is one of *ast.CaseClause, *ast.TypeCaseClause, *ast.CommClause;
p.print(newline); p.print(newline);
p.stmt(s); p.stmt(s);
......
...@@ -282,7 +282,7 @@ func TestLineComments(t *testing.T) { ...@@ -282,7 +282,7 @@ func TestLineComments(t *testing.T) {
var S Scanner; var S Scanner;
S.Init("TestLineComments", strings.Bytes(src), nil, 0); S.Init("TestLineComments", strings.Bytes(src), nil, 0);
for _, s := range segments { for _, s := range segments {
pos, tok, lit := S.Scan(); pos, _, lit := S.Scan();
checkPos(t, string(lit), pos, token.Position{s.filename, pos.Offset, s.line, pos.Column}); checkPos(t, string(lit), pos, token.Position{s.filename, pos.Offset, s.line, pos.Column});
} }
...@@ -300,14 +300,14 @@ func TestInit(t *testing.T) { ...@@ -300,14 +300,14 @@ func TestInit(t *testing.T) {
s.Init("", strings.Bytes("if true { }"), nil, 0); s.Init("", strings.Bytes("if true { }"), nil, 0);
s.Scan(); // if s.Scan(); // if
s.Scan(); // true s.Scan(); // true
pos, tok, lit := s.Scan(); // { _, tok, _ := s.Scan(); // {
if tok != token.LBRACE { if tok != token.LBRACE {
t.Errorf("bad token: got %s, expected %s", tok.String(), token.LBRACE); t.Errorf("bad token: got %s, expected %s", tok.String(), token.LBRACE);
} }
// 2nd init // 2nd init
s.Init("", strings.Bytes("go true { ]"), nil, 0); s.Init("", strings.Bytes("go true { ]"), nil, 0);
pos, tok, lit = s.Scan(); // go _, tok, _ = s.Scan(); // go
if tok != token.GO { if tok != token.GO {
t.Errorf("bad token: got %s, expected %s", tok.String(), token.GO); t.Errorf("bad token: got %s, expected %s", tok.String(), token.GO);
} }
......
...@@ -42,7 +42,7 @@ func TestUintCodec(t *testing.T) { ...@@ -42,7 +42,7 @@ func TestUintCodec(t *testing.T) {
b := new(bytes.Buffer); b := new(bytes.Buffer);
encState := new(encoderState); encState := new(encoderState);
encState.b = b; encState.b = b;
for i, tt := range encodeT { for _, tt := range encodeT {
b.Reset(); b.Reset();
encodeUint(encState, tt.x); encodeUint(encState, tt.x);
if encState.err != nil { if encState.err != nil {
......
...@@ -45,7 +45,7 @@ func overflow(name string) os.ErrorString { ...@@ -45,7 +45,7 @@ func overflow(name string) os.ErrorString {
// decodeUintReader reads an encoded unsigned integer from an io.Reader. // decodeUintReader reads an encoded unsigned integer from an io.Reader.
// Used only by the Decoder to read the message length. // Used only by the Decoder to read the message length.
func decodeUintReader(r io.Reader, buf []byte) (x uint64, err os.Error) { func decodeUintReader(r io.Reader, buf []byte) (x uint64, err os.Error) {
n1, err := r.Read(buf[0:1]); _, err = r.Read(buf[0:1]);
if err != nil { if err != nil {
return return
} }
......
...@@ -37,7 +37,7 @@ func NewDecoder(r io.Reader) *Decoder { ...@@ -37,7 +37,7 @@ func NewDecoder(r io.Reader) *Decoder {
func (dec *Decoder) recvType(id typeId) { func (dec *Decoder) recvType(id typeId) {
// Have we already seen this type? That's an error // Have we already seen this type? That's an error
if wt_, alreadySeen := dec.seen[id]; alreadySeen { if _, alreadySeen := dec.seen[id]; alreadySeen {
dec.state.err = os.ErrorString("gob: duplicate type received"); dec.state.err = os.ErrorString("gob: duplicate type received");
return return
} }
...@@ -54,8 +54,6 @@ func (dec *Decoder) recvType(id typeId) { ...@@ -54,8 +54,6 @@ func (dec *Decoder) recvType(id typeId) {
// The value underlying e must be the correct type for the next // The value underlying e must be the correct type for the next
// data item received. // data item received.
func (dec *Decoder) Decode(e interface{}) os.Error { func (dec *Decoder) Decode(e interface{}) os.Error {
rt, indir := indirect(reflect.Typeof(e));
// Make sure we're single-threaded through here. // Make sure we're single-threaded through here.
dec.mutex.Lock(); dec.mutex.Lock();
defer dec.mutex.Unlock(); defer dec.mutex.Unlock();
......
...@@ -372,7 +372,7 @@ func encOpFor(rt reflect.Type) (encOp, int, os.Error) { ...@@ -372,7 +372,7 @@ func encOpFor(rt reflect.Type) (encOp, int, os.Error) {
}; };
case *reflect.StructType: case *reflect.StructType:
// Generate a closure that calls out to the engine for the nested type. // Generate a closure that calls out to the engine for the nested type.
engine, err := getEncEngine(typ); _, err := getEncEngine(typ);
if err != nil { if err != nil {
return nil, 0, err return nil, 0, err
} }
......
...@@ -237,7 +237,7 @@ func (enc *Encoder) send() { ...@@ -237,7 +237,7 @@ func (enc *Encoder) send() {
func (enc *Encoder) sendType(origt reflect.Type) { func (enc *Encoder) sendType(origt reflect.Type) {
// Drill down to the base type. // Drill down to the base type.
rt, indir_ := indirect(origt); rt, _ := indirect(origt);
// We only send structs - everything else is basic or an error // We only send structs - everything else is basic or an error
switch rt.(type) { switch rt.(type) {
...@@ -259,7 +259,7 @@ func (enc *Encoder) sendType(origt reflect.Type) { ...@@ -259,7 +259,7 @@ func (enc *Encoder) sendType(origt reflect.Type) {
} }
// Have we already sent this type? This time we ask about the base type. // Have we already sent this type? This time we ask about the base type.
if id_, alreadySent := enc.sent[rt]; alreadySent { if _, alreadySent := enc.sent[rt]; alreadySent {
return return
} }
...@@ -296,7 +296,7 @@ func (enc *Encoder) Encode(e interface{}) os.Error { ...@@ -296,7 +296,7 @@ func (enc *Encoder) Encode(e interface{}) os.Error {
if enc.state.b.Len() > 0 || enc.countState.b.Len() > 0 { if enc.state.b.Len() > 0 || enc.countState.b.Len() > 0 {
panicln("Encoder: buffer not empty") panicln("Encoder: buffer not empty")
} }
rt, indir := indirect(reflect.Typeof(e)); rt, _ := indirect(reflect.Typeof(e));
// Make sure we're single-threaded through here. // Make sure we're single-threaded through here.
enc.mutex.Lock(); enc.mutex.Lock();
...@@ -304,7 +304,7 @@ func (enc *Encoder) Encode(e interface{}) os.Error { ...@@ -304,7 +304,7 @@ func (enc *Encoder) Encode(e interface{}) os.Error {
// Make sure the type is known to the other side. // Make sure the type is known to the other side.
// First, have we already sent this type? // First, have we already sent this type?
if id_, alreadySent := enc.sent[rt]; !alreadySent { if _, alreadySent := enc.sent[rt]; !alreadySent {
// No, so send it. // No, so send it.
enc.sendType(rt); enc.sendType(rt);
if enc.state.err != nil { if enc.state.err != nil {
......
...@@ -292,7 +292,7 @@ func newTypeObject(name string, rt reflect.Type) (gobType, os.Error) { ...@@ -292,7 +292,7 @@ func newTypeObject(name string, rt reflect.Type) (gobType, os.Error) {
field := make([]*fieldType, t.NumField()); field := make([]*fieldType, t.NumField());
for i := 0; i < t.NumField(); i++ { for i := 0; i < t.NumField(); i++ {
f := t.Field(i); f := t.Field(i);
typ, _indir := indirect(f.Type); typ, _ := indirect(f.Type);
tname := typ.Name(); tname := typ.Name();
if tname == "" { if tname == "" {
tname = f.Type.String(); tname = f.Type.String();
...@@ -384,7 +384,7 @@ var typeInfoMap = make(map[reflect.Type] *typeInfo) // protected by typeLock ...@@ -384,7 +384,7 @@ var typeInfoMap = make(map[reflect.Type] *typeInfo) // protected by typeLock
// The reflection type must have all its indirections processed out. // The reflection type must have all its indirections processed out.
// typeLock must be held. // typeLock must be held.
func getTypeInfo(rt reflect.Type) (*typeInfo, os.Error) { func getTypeInfo(rt reflect.Type) (*typeInfo, os.Error) {
if pt, ok := rt.(*reflect.PtrType); ok { if _, ok := rt.(*reflect.PtrType); ok {
panicln("pointer type in getTypeInfo:", rt.String()) panicln("pointer type in getTypeInfo:", rt.String())
} }
info, ok := typeInfoMap[rt]; info, ok := typeInfoMap[rt];
......
...@@ -40,7 +40,7 @@ type Response struct { ...@@ -40,7 +40,7 @@ type Response struct {
// response headers with the given key, it returns the empty string and // response headers with the given key, it returns the empty string and
// false. Keys are not case sensitive. // false. Keys are not case sensitive.
func (r *Response) GetHeader(key string) (value string) { func (r *Response) GetHeader(key string) (value string) {
value, present := r.Header[CanonicalHeaderKey(key)]; value, _ = r.Header[CanonicalHeaderKey(key)];
return; return;
} }
......
...@@ -17,7 +17,7 @@ func TestClient(t *testing.T) { ...@@ -17,7 +17,7 @@ func TestClient(t *testing.T) {
// TODO: add a proper test suite. Current test merely verifies that // TODO: add a proper test suite. Current test merely verifies that
// we can retrieve the Google robots.txt file. // we can retrieve the Google robots.txt file.
r, url, err := Get("http://www.google.com/robots.txt"); r, _, err := Get("http://www.google.com/robots.txt");
var b []byte; var b []byte;
if err == nil { if err == nil {
b, err = io.ReadAll(r.Body); b, err = io.ReadAll(r.Body);
......
...@@ -58,7 +58,7 @@ func dirList(c *Conn, f *os.File) { ...@@ -58,7 +58,7 @@ func dirList(c *Conn, f *os.File) {
if err != nil || len(dirs) == 0 { if err != nil || len(dirs) == 0 {
break break
} }
for i, d := range dirs { for _, d := range dirs {
name := d.Name; name := d.Name;
if d.IsDirectory() { if d.IsDirectory() {
name += "/" name += "/"
...@@ -141,7 +141,7 @@ func serveFileInternal(c *Conn, r *Request, name string, redirect bool) { ...@@ -141,7 +141,7 @@ func serveFileInternal(c *Conn, r *Request, name string, redirect bool) {
} else { } else {
// read first chunk to decide between utf-8 text and binary // read first chunk to decide between utf-8 text and binary
var buf [1024]byte; var buf [1024]byte;
n, err := io.ReadFull(f, &buf); n, _ := io.ReadFull(f, &buf);
b := buf[0:n]; b := buf[0:n];
if isText(b) { if isText(b) {
c.SetHeader("Content-Type", "text-plain; charset=utf-8"); c.SetHeader("Content-Type", "text-plain; charset=utf-8");
......
...@@ -508,7 +508,7 @@ func ReadRequest(b *bufio.Reader) (req *Request, err os.Error) { ...@@ -508,7 +508,7 @@ func ReadRequest(b *bufio.Reader) (req *Request, err os.Error) {
// like // like
// Cache-Control: no-cache // Cache-Control: no-cache
if v, present := req.Header["Pragma"]; present && v == "no-cache" { if v, present := req.Header["Pragma"]; present && v == "no-cache" {
if cc, presentcc := req.Header["Cache-Control"]; !presentcc { if _, presentcc := req.Header["Cache-Control"]; !presentcc {
req.Header["Cache-Control"] = "no-cache" req.Header["Cache-Control"] = "no-cache"
} }
} }
......
...@@ -367,7 +367,7 @@ func Redirect(c *Conn, url string, code int) { ...@@ -367,7 +367,7 @@ func Redirect(c *Conn, url string, code int) {
// no leading http://server // no leading http://server
if url == "" || url[0] != '/' { if url == "" || url[0] != '/' {
// make relative path absolute // make relative path absolute
olddir, oldfile := path.Split(oldpath); olddir, _ := path.Split(oldpath);
url = olddir + url; url = olddir + url;
} }
......
...@@ -190,7 +190,7 @@ func ufmt(u *URL) string { ...@@ -190,7 +190,7 @@ func ufmt(u *URL) string {
} }
func DoTest(t *testing.T, parse func(string) (*URL, os.Error), name string, tests []URLTest) { func DoTest(t *testing.T, parse func(string) (*URL, os.Error), name string, tests []URLTest) {
for i, tt := range tests { for _, tt := range tests {
u, err := parse(tt.in); u, err := parse(tt.in);
if err != nil { if err != nil {
t.Errorf("%s(%q) returned error %s", name, tt.in, err); t.Errorf("%s(%q) returned error %s", name, tt.in, err);
...@@ -214,7 +214,7 @@ func TestParseURLReference(t *testing.T) { ...@@ -214,7 +214,7 @@ func TestParseURLReference(t *testing.T) {
} }
func DoTestString(t *testing.T, parse func(string) (*URL, os.Error), name string, tests []URLTest) { func DoTestString(t *testing.T, parse func(string) (*URL, os.Error), name string, tests []URLTest) {
for i, tt := range tests { for _, tt := range tests {
u, err := parse(tt.in); u, err := parse(tt.in);
if err != nil { if err != nil {
t.Errorf("%s(%q) returned error %s", name, tt.in, err); t.Errorf("%s(%q) returned error %s", name, tt.in, err);
...@@ -305,7 +305,7 @@ var unescapeTests = []URLEscapeTest { ...@@ -305,7 +305,7 @@ var unescapeTests = []URLEscapeTest {
} }
func TestURLUnescape(t *testing.T) { func TestURLUnescape(t *testing.T) {
for i, tt := range unescapeTests { for _, tt := range unescapeTests {
actual, err := URLUnescape(tt.in); actual, err := URLUnescape(tt.in);
if actual != tt.out || (err != nil) != (tt.err != nil) { if actual != tt.out || (err != nil) != (tt.err != nil) {
t.Errorf("URLUnescape(%q) = %q, %s; want %q, %s", tt.in, actual, err, tt.out, tt.err); t.Errorf("URLUnescape(%q) = %q, %s; want %q, %s", tt.in, actual, err, tt.out, tt.err);
...@@ -342,7 +342,7 @@ var escapeTests = []URLEscapeTest { ...@@ -342,7 +342,7 @@ var escapeTests = []URLEscapeTest {
} }
func TestURLEscape(t *testing.T) { func TestURLEscape(t *testing.T) {
for i, tt := range escapeTests { for _, tt := range escapeTests {
actual := URLEscape(tt.in); actual := URLEscape(tt.in);
if tt.out != actual { if tt.out != actual {
t.Errorf("URLEscape(%q) = %q, want %q", tt.in, actual, tt.out); t.Errorf("URLEscape(%q) = %q, want %q", tt.in, actual, tt.out);
......
...@@ -185,7 +185,7 @@ func (p PalettedColorModel) Convert(c Color) Color { ...@@ -185,7 +185,7 @@ func (p PalettedColorModel) Convert(c Color) Color {
// TODO(nigeltao): Revisit the "pick the palette color which minimizes sum-squared-difference" // TODO(nigeltao): Revisit the "pick the palette color which minimizes sum-squared-difference"
// algorithm when the premultiplied vs unpremultiplied issue is resolved. // algorithm when the premultiplied vs unpremultiplied issue is resolved.
// Currently, we only compare the R, G and B values, and ignore A. // Currently, we only compare the R, G and B values, and ignore A.
cr, cg, cb, ca := c.RGBA(); cr, cg, cb, _ := c.RGBA();
// Shift by 17 bits to avoid potential uint32 overflow in sum-squared-difference. // Shift by 17 bits to avoid potential uint32 overflow in sum-squared-difference.
cr >>= 17; cr >>= 17;
cg >>= 17; cg >>= 17;
...@@ -193,7 +193,7 @@ func (p PalettedColorModel) Convert(c Color) Color { ...@@ -193,7 +193,7 @@ func (p PalettedColorModel) Convert(c Color) Color {
result := Color(nil); result := Color(nil);
bestSSD := uint32(1<<32 - 1); bestSSD := uint32(1<<32 - 1);
for _, v := range p { for _, v := range p {
vr, vg, vb, va := v.RGBA(); vr, vg, vb, _ := v.RGBA();
vr >>= 17; vr >>= 17;
vg >>= 17; vg >>= 17;
vb >>= 17; vb >>= 17;
......
...@@ -106,7 +106,7 @@ func (d *decoder) parseIHDR(r io.Reader, crc hash.Hash32, length uint32) os.Erro ...@@ -106,7 +106,7 @@ func (d *decoder) parseIHDR(r io.Reader, crc hash.Hash32, length uint32) os.Erro
if length != 13 { if length != 13 {
return FormatError("bad IHDR length"); return FormatError("bad IHDR length");
} }
n, err := io.ReadFull(r, d.scratch[0:13]); _, err := io.ReadFull(r, d.scratch[0:13]);
if err != nil { if err != nil {
return err; return err;
} }
...@@ -402,7 +402,7 @@ func (d *decoder) parseChunk(r io.Reader) os.Error { ...@@ -402,7 +402,7 @@ func (d *decoder) parseChunk(r io.Reader) os.Error {
} }
func (d *decoder) checkHeader(r io.Reader) os.Error { func (d *decoder) checkHeader(r io.Reader) os.Error {
n, err := io.ReadFull(r, d.scratch[0:8]); _, err := io.ReadFull(r, d.scratch[0:8]);
if err != nil { if err != nil {
return err; return err;
} }
......
...@@ -14,7 +14,7 @@ import ( ...@@ -14,7 +14,7 @@ import (
// ReadAll reads from r until an error or EOF and returns the data it read. // ReadAll reads from r until an error or EOF and returns the data it read.
func ReadAll(r Reader) ([]byte, os.Error) { func ReadAll(r Reader) ([]byte, os.Error) {
var buf bytes.Buffer; var buf bytes.Buffer;
n, err := Copy(r, &buf); _, err := Copy(r, &buf);
return buf.Data(), err; return buf.Data(), err;
} }
......
...@@ -97,7 +97,7 @@ func (l *Logger) formatHeader(ns int64, calldepth int) string { ...@@ -97,7 +97,7 @@ func (l *Logger) formatHeader(ns int64, calldepth int) string {
} }
} }
if l.flag & (Lshortfile | Llongfile) != 0 { if l.flag & (Lshortfile | Llongfile) != 0 {
pc, file, line, ok := runtime.Caller(calldepth); _, file, line, ok := runtime.Caller(calldepth);
if ok { if ok {
if l.flag & Lshortfile != 0 { if l.flag & Lshortfile != 0 {
short, ok := shortnames[file]; short, ok := shortnames[file];
......
...@@ -75,7 +75,7 @@ func testLog(t *testing.T, flag int, prefix string, pattern string, useLogf bool ...@@ -75,7 +75,7 @@ func testLog(t *testing.T, flag int, prefix string, pattern string, useLogf bool
} }
func TestAllLog(t *testing.T) { func TestAllLog(t *testing.T) {
for i, testcase := range tests { for _, testcase := range tests {
testLog(t, testcase.flag, testcase.prefix, testcase.pattern, false); testLog(t, testcase.flag, testcase.prefix, testcase.pattern, false);
testLog(t, testcase.flag, testcase.prefix, testcase.pattern, true); testLog(t, testcase.flag, testcase.prefix, testcase.pattern, true);
} }
......
...@@ -14,7 +14,7 @@ func Floor(x float64) float64 { ...@@ -14,7 +14,7 @@ func Floor(x float64) float64 {
} }
return -d; return -d;
} }
d, fract := Modf(x); d, _ := Modf(x);
return d; return d;
} }
......
...@@ -29,7 +29,7 @@ func sinus(x float64, quad int) float64 { ...@@ -29,7 +29,7 @@ func sinus(x float64, quad int) float64 {
var e float64; var e float64;
e, y = Modf(x); e, y = Modf(x);
e = e + float64(quad); e = e + float64(quad);
temp1, f := Modf(0.25*e); _, f := Modf(0.25*e);
quad = int(e - 4*f); quad = int(e - 4*f);
} else { } else {
k := int32(x); k := int32(x);
......
...@@ -79,19 +79,19 @@ func _DNS_ReadConfig() (*_DNS_Config, os.Error) { ...@@ -79,19 +79,19 @@ func _DNS_ReadConfig() (*_DNS_Config, os.Error) {
s := f[i]; s := f[i];
switch { switch {
case len(s) >= 6 && s[0:6] == "ndots:": case len(s) >= 6 && s[0:6] == "ndots:":
n, i, ok := dtoi(s, 6); n, _, _ := dtoi(s, 6);
if n < 1 { if n < 1 {
n = 1 n = 1
} }
conf.ndots = n; conf.ndots = n;
case len(s) >= 8 && s[0:8] == "timeout:": case len(s) >= 8 && s[0:8] == "timeout:":
n, i, ok := dtoi(s, 8); n, _, _ := dtoi(s, 8);
if n < 1 { if n < 1 {
n = 1 n = 1
} }
conf.timeout = n; conf.timeout = n;
case len(s) >= 8 && s[0:9] == "attempts:": case len(s) >= 8 && s[0:9] == "attempts:":
n, i, ok := dtoi(s, 9); n, _, _ := dtoi(s, 9);
if n < 1 { if n < 1 {
n = 1 n = 1
} }
......
...@@ -244,8 +244,8 @@ func (s *pollServer) Run() { ...@@ -244,8 +244,8 @@ func (s *pollServer) Run() {
} }
if fd == s.pr.Fd() { if fd == s.pr.Fd() {
// Drain our wakeup pipe. // Drain our wakeup pipe.
for nn, e := s.pr.Read(&scratch); nn > 0; { for nn, _ := s.pr.Read(&scratch); nn > 0; {
nn, e = s.pr.Read(&scratch) nn, _ = s.pr.Read(&scratch)
} }
// Read from channels // Read from channels
...@@ -327,7 +327,7 @@ func (fd *netFD) addr() string { ...@@ -327,7 +327,7 @@ func (fd *netFD) addr() string {
if e != 0 { if e != 0 {
return ""; return "";
} }
addr, err := sockaddrToString(sa); addr, _ := sockaddrToString(sa);
return addr; return addr;
} }
...@@ -336,7 +336,7 @@ func (fd *netFD) remoteAddr() string { ...@@ -336,7 +336,7 @@ func (fd *netFD) remoteAddr() string {
if e != 0 { if e != 0 {
return ""; return "";
} }
addr, err := sockaddrToString(sa); addr, _ := sockaddrToString(sa);
return addr; return addr;
} }
......
...@@ -220,7 +220,7 @@ func hostPortToIP(net, hostport, mode string) (ip IP, iport int, err os.Error) { ...@@ -220,7 +220,7 @@ func hostPortToIP(net, hostport, mode string) (ip IP, iport int, err os.Error) {
} }
if addr == nil { if addr == nil {
// Not an IP address. Try as a DNS name. // Not an IP address. Try as a DNS name.
hostname, addrs, err1 := LookupHost(host); _, addrs, err1 := LookupHost(host);
if err1 != nil { if err1 != nil {
err = err1; err = err1;
goto Error; goto Error;
......
...@@ -63,7 +63,7 @@ func TestDialError(t *testing.T) { ...@@ -63,7 +63,7 @@ func TestDialError(t *testing.T) {
continue; continue;
} }
s := e.String(); s := e.String();
match, err := regexp.MatchString(tt.Pattern, s); match, _ := regexp.MatchString(tt.Pattern, s);
if !match { if !match {
t.Errorf("#%d: %q, want match for %#q", i, s, tt.Pattern); t.Errorf("#%d: %q, want match for %#q", i, s, tt.Pattern);
} }
......
...@@ -46,7 +46,7 @@ func (f *file) readLine() (s string, ok bool) { ...@@ -46,7 +46,7 @@ func (f *file) readLine() (s string, ok bool) {
} }
if len(f.data) < cap(f.data) { if len(f.data) < cap(f.data) {
ln := len(f.data); ln := len(f.data);
n, err := io.ReadFull(f.file, f.data[ln:cap(f.data)]); n, _ := io.ReadFull(f.file, f.data[ln:cap(f.data)]);
if n >= 0 { if n >= 0 {
f.data = f.data[0:ln+n]; f.data = f.data[0:ln+n];
} }
......
...@@ -33,7 +33,7 @@ func runServe(t *testing.T, network, addr string, listening chan<- string, done ...@@ -33,7 +33,7 @@ func runServe(t *testing.T, network, addr string, listening chan<- string, done
listening <- l.Addr(); listening <- l.Addr();
for { for {
fd, addr, err := l.Accept(); fd, _, err := l.Accept();
if err != nil { if err != nil {
break; break;
} }
......
...@@ -18,7 +18,7 @@ var env map[string] string; ...@@ -18,7 +18,7 @@ var env map[string] string;
func copyenv() { func copyenv() {
env = make(map[string] string); env = make(map[string] string);
for i, s := range Envs { for _, s := range Envs {
for j := 0; j < len(s); j++ { for j := 0; j < len(s); j++ {
if s[j] == '=' { if s[j] == '=' {
env[s[0:j]] = s[j+1:len(s)]; env[s[0:j]] = s[j+1:len(s)];
......
...@@ -148,12 +148,12 @@ func (w Waitmsg) String() string { ...@@ -148,12 +148,12 @@ func (w Waitmsg) String() string {
// Getpid returns the process id of the caller. // Getpid returns the process id of the caller.
func Getpid() int { func Getpid() int {
p, r2, e := syscall.Syscall(syscall.SYS_GETPID, 0, 0, 0); p, _, _ := syscall.Syscall(syscall.SYS_GETPID, 0, 0, 0);
return int(p) return int(p)
} }
// Getppid returns the process id of the caller's parent. // Getppid returns the process id of the caller's parent.
func Getppid() int { func Getppid() int {
p, r2, e := syscall.Syscall(syscall.SYS_GETPPID, 0, 0, 0); p, _, _ := syscall.Syscall(syscall.SYS_GETPPID, 0, 0, 0);
return int(p) return int(p)
} }
...@@ -65,8 +65,8 @@ func Getwd() (string, Error) { ...@@ -65,8 +65,8 @@ func Getwd() (string, Error) {
fd.Close(); fd.Close();
return "", err; return "", err;
} }
for i, name := range names { for _, name := range names {
d, err := Lstat(parent + "/" + name); d, _ := Lstat(parent + "/" + name);
if d.Dev == dot.Dev && d.Ino == dot.Ino { if d.Dev == dot.Dev && d.Ino == dot.Ino {
pwd = "/" + name + pwd; pwd = "/" + name + pwd;
goto Found; goto Found;
......
...@@ -110,9 +110,9 @@ func testReaddirnames(dir string, contents []string, t *testing.T) { ...@@ -110,9 +110,9 @@ func testReaddirnames(dir string, contents []string, t *testing.T) {
if err2 != nil { if err2 != nil {
t.Fatalf("readdirnames %q failed: %v", err2); t.Fatalf("readdirnames %q failed: %v", err2);
} }
for i, m := range contents { for _, m := range contents {
found := false; found := false;
for j, n := range s { for _, n := range s {
if n == "." || n == ".." { if n == "." || n == ".." {
t.Errorf("got %s in directory", n); t.Errorf("got %s in directory", n);
} }
...@@ -139,9 +139,9 @@ func testReaddir(dir string, contents []string, t *testing.T) { ...@@ -139,9 +139,9 @@ func testReaddir(dir string, contents []string, t *testing.T) {
if err2 != nil { if err2 != nil {
t.Fatalf("readdir %q failed: %v", dir, err2); t.Fatalf("readdir %q failed: %v", dir, err2);
} }
for i, m := range contents { for _, m := range contents {
found := false; found := false;
for j, n := range s { for _, n := range s {
if m == n.Name { if m == n.Name {
if found { if found {
t.Error("present twice:", m); t.Error("present twice:", m);
...@@ -412,7 +412,7 @@ func TestChown(t *testing.T) { ...@@ -412,7 +412,7 @@ func TestChown(t *testing.T) {
t.Fatalf("getgroups: %s", err); t.Fatalf("getgroups: %s", err);
} }
t.Log("groups: ", groups); t.Log("groups: ", groups);
for i, g := range groups { for _, g := range groups {
if err = Chown(Path, -1, g); err != nil { if err = Chown(Path, -1, g); err != nil {
t.Fatalf("chown %s -1 %d: %s", Path, g, err); t.Fatalf("chown %s -1 %d: %s", Path, g, err);
} }
...@@ -468,7 +468,7 @@ func TestChdirAndGetwd(t *testing.T) { ...@@ -468,7 +468,7 @@ func TestChdirAndGetwd(t *testing.T) {
// (unlike, say, /var, /etc, and /tmp). // (unlike, say, /var, /etc, and /tmp).
dirs := []string{ "/bin", "/", "/usr/bin" }; dirs := []string{ "/bin", "/", "/usr/bin" };
for mode := 0; mode < 2; mode++ { for mode := 0; mode < 2; mode++ {
for i, d := range dirs { for _, d := range dirs {
if mode == 0 { if mode == 0 {
err = Chdir(d); err = Chdir(d);
} else { } else {
...@@ -577,7 +577,7 @@ var openErrorTests = []openErrorTest { ...@@ -577,7 +577,7 @@ var openErrorTests = []openErrorTest {
} }
func TestOpenError(t *testing.T) { func TestOpenError(t *testing.T) {
for i, tt := range openErrorTests { for _, tt := range openErrorTests {
f, err := Open(tt.path, tt.mode, 0); f, err := Open(tt.path, tt.mode, 0);
if err == nil { if err == nil {
t.Errorf("Open(%q, %d) succeeded", tt.path, tt.mode); t.Errorf("Open(%q, %d) succeeded", tt.path, tt.mode);
......
...@@ -90,7 +90,7 @@ func RemoveAll(path string) Error { ...@@ -90,7 +90,7 @@ func RemoveAll(path string) Error {
err = nil; err = nil;
for { for {
names, err1 := fd.Readdirnames(100); names, err1 := fd.Readdirnames(100);
for i, name := range names { for _, name := range names {
err1 := RemoveAll(path + "/" + name); err1 := RemoveAll(path + "/" + name);
if err == nil { if err == nil {
err = err1; err = err1;
......
...@@ -26,7 +26,7 @@ func TestMkdirAll(t *testing.T) { ...@@ -26,7 +26,7 @@ func TestMkdirAll(t *testing.T) {
// Make file. // Make file.
fpath := path + "/file"; fpath := path + "/file";
fd, err := Open(fpath, O_WRONLY | O_CREAT, 0666); _, err = Open(fpath, O_WRONLY | O_CREAT, 0666);
if err != nil { if err != nil {
t.Fatalf("create %q: %s", fpath, err); t.Fatalf("create %q: %s", fpath, err);
} }
...@@ -79,7 +79,7 @@ func TestRemoveAll(t *testing.T) { ...@@ -79,7 +79,7 @@ func TestRemoveAll(t *testing.T) {
if err = RemoveAll(path); err != nil { if err = RemoveAll(path); err != nil {
t.Fatalf("RemoveAll %q (first): %s", path, err); t.Fatalf("RemoveAll %q (first): %s", path, err);
} }
if dir, err := Lstat(path); err == nil { if _, err := Lstat(path); err == nil {
t.Fatalf("Lstat %q succeeded after RemoveAll (first)", path); t.Fatalf("Lstat %q succeeded after RemoveAll (first)", path);
} }
...@@ -100,7 +100,7 @@ func TestRemoveAll(t *testing.T) { ...@@ -100,7 +100,7 @@ func TestRemoveAll(t *testing.T) {
if err = RemoveAll(path); err != nil { if err = RemoveAll(path); err != nil {
t.Fatalf("RemoveAll %q (second): %s", path, err); t.Fatalf("RemoveAll %q (second): %s", path, err);
} }
if dir, err := Lstat(path); err == nil { if _, err := Lstat(path); err == nil {
t.Fatalf("Lstat %q succeeded after RemoveAll (second)", path); t.Fatalf("Lstat %q succeeded after RemoveAll (second)", path);
} }
...@@ -109,7 +109,7 @@ func TestRemoveAll(t *testing.T) { ...@@ -109,7 +109,7 @@ func TestRemoveAll(t *testing.T) {
t.Fatalf("MkdirAll %q: %s", dpath, err); t.Fatalf("MkdirAll %q: %s", dpath, err);
} }
for i, s := range []string{fpath, dpath+"/file1", path+"/zzz"} { for _, s := range []string{fpath, dpath+"/file1", path+"/zzz"} {
fd, err = Open(s, O_WRONLY | O_CREAT, 0666); fd, err = Open(s, O_WRONLY | O_CREAT, 0666);
if err != nil { if err != nil {
t.Fatalf("create %q: %s", s, err); t.Fatalf("create %q: %s", s, err);
...@@ -120,7 +120,7 @@ func TestRemoveAll(t *testing.T) { ...@@ -120,7 +120,7 @@ func TestRemoveAll(t *testing.T) {
t.Fatalf("Chmod %q 0: %s", dpath, err); t.Fatalf("Chmod %q 0: %s", dpath, err);
} }
if err = RemoveAll(path); err == nil { if err = RemoveAll(path); err == nil {
dir, err := Lstat(path); _, err := Lstat(path);
if err == nil { if err == nil {
t.Errorf("Can lstat %q after supposed RemoveAll", path); t.Errorf("Can lstat %q after supposed RemoveAll", path);
} }
...@@ -136,15 +136,15 @@ func TestRemoveAll(t *testing.T) { ...@@ -136,15 +136,15 @@ func TestRemoveAll(t *testing.T) {
if err = Chmod(dpath, 0777); err != nil { if err = Chmod(dpath, 0777); err != nil {
t.Fatalf("Chmod %q 0777: %s", dpath, err); t.Fatalf("Chmod %q 0777: %s", dpath, err);
} }
for i, s := range []string{fpath, path+"/zzz"} { for _, s := range []string{fpath, path+"/zzz"} {
if dir, err := Lstat(s); err == nil { if _, err := Lstat(s); err == nil {
t.Fatalf("Lstat %q succeeded after partial RemoveAll", s); t.Fatalf("Lstat %q succeeded after partial RemoveAll", s);
} }
} }
if err = RemoveAll(path); err != nil { if err = RemoveAll(path); err != nil {
t.Fatalf("RemoveAll %q after partial RemoveAll: %s", path, err); t.Fatalf("RemoveAll %q after partial RemoveAll: %s", path, err);
} }
if dir, err := Lstat(path); err == nil { if _, err := Lstat(path); err == nil {
t.Fatalf("Lstat %q succeeded after RemoveAll (final)", path); t.Fatalf("Lstat %q succeeded after RemoveAll (final)", path);
} }
} }
...@@ -63,7 +63,7 @@ var cleantests = []CleanTest { ...@@ -63,7 +63,7 @@ var cleantests = []CleanTest {
} }
func TestClean(t *testing.T) { func TestClean(t *testing.T) {
for i, test := range cleantests { for _, test := range cleantests {
if s := Clean(test.path); s != test.clean { if s := Clean(test.path); s != test.clean {
t.Errorf("Clean(%q) = %q, want %q", test.path, s, test.clean); t.Errorf("Clean(%q) = %q, want %q", test.path, s, test.clean);
} }
...@@ -83,7 +83,7 @@ var splittests = []SplitTest { ...@@ -83,7 +83,7 @@ var splittests = []SplitTest {
} }
func TestSplit(t *testing.T) { func TestSplit(t *testing.T) {
for i, test := range splittests { for _, test := range splittests {
if d, f := Split(test.path); d != test.dir || f != test.file { if d, f := Split(test.path); d != test.dir || f != test.file {
t.Errorf("Split(%q) = %q, %q, want %q, %q", test.path, d, f, test.dir, test.file); t.Errorf("Split(%q) = %q, %q, want %q, %q", test.path, d, f, test.dir, test.file);
} }
...@@ -105,7 +105,7 @@ var jointests = []JoinTest { ...@@ -105,7 +105,7 @@ var jointests = []JoinTest {
} }
func TestJoin(t *testing.T) { func TestJoin(t *testing.T) {
for i, test := range jointests { for _, test := range jointests {
if p := Join(test.dir, test.file); p != test.path { if p := Join(test.dir, test.file); p != test.path {
t.Errorf("Join(%q, %q) = %q, want %q", test.dir, test.file, p, test.path); t.Errorf("Join(%q, %q) = %q, want %q", test.dir, test.file, p, test.path);
} }
...@@ -125,7 +125,7 @@ var exttests = []ExtTest { ...@@ -125,7 +125,7 @@ var exttests = []ExtTest {
} }
func TestExt(t *testing.T) { func TestExt(t *testing.T) {
for i, test := range exttests { for _, test := range exttests {
if x := Ext(test.path); x != test.ext { if x := Ext(test.path); x != test.ext {
t.Errorf("Ext(%q) = %q, want %q", test.path, x, test.ext); t.Errorf("Ext(%q) = %q, want %q", test.path, x, test.ext);
} }
......
...@@ -266,7 +266,7 @@ func TestInterfaceValue(t *testing.T) { ...@@ -266,7 +266,7 @@ func TestInterfaceValue(t *testing.T) {
assert(t, v3.Type().String(), "float"); assert(t, v3.Type().String(), "float");
i3 := v2.Interface(); i3 := v2.Interface();
if f, ok := i3.(float); !ok { if _, ok := i3.(float); !ok {
t.Error("v2.Interface() did not return float, got ", Typeof(i3)); t.Error("v2.Interface() did not return float, got ", Typeof(i3));
} }
} }
...@@ -392,7 +392,7 @@ var deepEqualTests = []DeepEqualTest { ...@@ -392,7 +392,7 @@ var deepEqualTests = []DeepEqualTest {
} }
func TestDeepEqual(t *testing.T) { func TestDeepEqual(t *testing.T) {
for i, test := range deepEqualTests { for _, test := range deepEqualTests {
if r := DeepEqual(test.a, test.b); r != test.eq { if r := DeepEqual(test.a, test.b); r != test.eq {
t.Errorf("DeepEqual(%v, %v) = %v, want %v", test.a, test.b, r, test.eq); t.Errorf("DeepEqual(%v, %v) = %v, want %v", test.a, test.b, r, test.eq);
} }
...@@ -400,7 +400,7 @@ func TestDeepEqual(t *testing.T) { ...@@ -400,7 +400,7 @@ func TestDeepEqual(t *testing.T) {
} }
func TestTypeof(t *testing.T) { func TestTypeof(t *testing.T) {
for i, test := range deepEqualTests { for _, test := range deepEqualTests {
v := NewValue(test.a); v := NewValue(test.a);
if v == nil { if v == nil {
continue; continue;
...@@ -510,10 +510,10 @@ func NotNil(a interface{}, t *testing.T) { ...@@ -510,10 +510,10 @@ func NotNil(a interface{}, t *testing.T) {
func TestIsNil(t *testing.T) { func TestIsNil(t *testing.T) {
// These do not implement IsNil // These do not implement IsNil
doNotNil := []interface{}{ int(0), float32(0), struct{a int}{} }; doNotNil := []interface{}{ int(0), float32(0), struct{a int}{} };
for i, ts := range doNotNil { for _, ts := range doNotNil {
ty := Typeof(ts); ty := Typeof(ts);
v := MakeZero(ty); v := MakeZero(ty);
if nilable, ok := v.(IsNiller); ok { if _, ok := v.(IsNiller); ok {
t.Errorf("%s is nilable; should not be", ts) t.Errorf("%s is nilable; should not be", ts)
} }
} }
...@@ -528,10 +528,10 @@ func TestIsNil(t *testing.T) { ...@@ -528,10 +528,10 @@ func TestIsNil(t *testing.T) {
struct{x chan int}{}, struct{x chan int}{},
struct{x []string}{} struct{x []string}{}
}; };
for i, ts := range doNil { for _, ts := range doNil {
ty := Typeof(ts).(*StructType).Field(0).Type; ty := Typeof(ts).(*StructType).Field(0).Type;
v := MakeZero(ty); v := MakeZero(ty);
if nilable, ok := v.(IsNiller); !ok { if _, ok := v.(IsNiller); !ok {
t.Errorf("%s %T is not nilable; should be", ts, v) t.Errorf("%s %T is not nilable; should be", ts, v)
} }
} }
......
...@@ -45,7 +45,7 @@ func deepValueEqual(v1, v2 Value, visited map[uintptr]*visit, depth int) bool { ...@@ -45,7 +45,7 @@ func deepValueEqual(v1, v2 Value, visited map[uintptr]*visit, depth int) bool {
// ... or already seen // ... or already seen
h := 17 * addr1 + addr2; h := 17 * addr1 + addr2;
seen, ok := visited[h]; seen, _ := visited[h];
typ := v1.Type(); typ := v1.Type();
for p := seen; p != nil; p = p.next { for p := seen; p != nil; p = p.next {
if p.a1 == addr1 && p.a2 == addr2 && p.typ == typ { if p.a1 == addr1 && p.a2 == addr2 && p.typ == typ {
...@@ -105,7 +105,7 @@ func deepValueEqual(v1, v2 Value, visited map[uintptr]*visit, depth int) bool { ...@@ -105,7 +105,7 @@ func deepValueEqual(v1, v2 Value, visited map[uintptr]*visit, depth int) bool {
if map1.Len() != map2.Len() { if map1.Len() != map2.Len() {
return false; return false;
} }
for i, k := range map1.Keys() { for _, k := range map1.Keys() {
if !deepValueEqual(map1.Elem(k), map2.Elem(k), visited, depth+1) { if !deepValueEqual(map1.Elem(k), map2.Elem(k), visited, depth+1) {
return false; return false;
} }
......
...@@ -1195,7 +1195,7 @@ func newFuncValue(typ Type, addr addr, canSet bool) *FuncValue { ...@@ -1195,7 +1195,7 @@ func newFuncValue(typ Type, addr addr, canSet bool) *FuncValue {
func newValue(typ Type, addr addr, canSet bool) Value { func newValue(typ Type, addr addr, canSet bool) Value {
// FuncValue has a different layout; // FuncValue has a different layout;
// it needs a extra space for the fixed receivers. // it needs a extra space for the fixed receivers.
if t, ok := typ.(*FuncType); ok { if _, ok := typ.(*FuncType); ok {
return newFuncValue(typ, addr, canSet); return newFuncValue(typ, addr, canSet);
} }
......
...@@ -348,7 +348,7 @@ var replaceTests = []ReplaceTest { ...@@ -348,7 +348,7 @@ var replaceTests = []ReplaceTest {
} }
func TestReplaceAll(t *testing.T) { func TestReplaceAll(t *testing.T) {
for i, tc := range replaceTests { for _, tc := range replaceTests {
re, err := Compile(tc.pattern); re, err := Compile(tc.pattern);
if err != nil { if err != nil {
t.Errorf("Unexpected error compiling %q: %v", tc.pattern, err); t.Errorf("Unexpected error compiling %q: %v", tc.pattern, err);
...@@ -379,7 +379,7 @@ var quoteMetaTests = []QuoteMetaTest { ...@@ -379,7 +379,7 @@ var quoteMetaTests = []QuoteMetaTest {
} }
func TestQuoteMeta(t *testing.T) { func TestQuoteMeta(t *testing.T) {
for i, tc := range quoteMetaTests { for _, tc := range quoteMetaTests {
// Verify that QuoteMeta returns the expected string. // Verify that QuoteMeta returns the expected string.
quoted := QuoteMeta(tc.pattern); quoted := QuoteMeta(tc.pattern);
if quoted != tc.output { if quoted != tc.output {
...@@ -449,7 +449,7 @@ func printStringSlice(t *testing.T, s []string) { ...@@ -449,7 +449,7 @@ func printStringSlice(t *testing.T, s []string) {
func TestAllMatches(t *testing.T) { func TestAllMatches(t *testing.T) {
ch := make(chan matchCase); ch := make(chan matchCase);
go func() { go func() {
for i, c := range matchCases { for _, c := range matchCases {
ch <- c; ch <- c;
stringCase := matchCase{ stringCase := matchCase{
"string" + c.matchfunc, "string" + c.matchfunc,
...@@ -464,7 +464,7 @@ func TestAllMatches(t *testing.T) { ...@@ -464,7 +464,7 @@ func TestAllMatches(t *testing.T) {
for c := range ch { for c := range ch {
var result []string; var result []string;
re, err := Compile(c.regexp); re, _ := Compile(c.regexp);
switch c.matchfunc { switch c.matchfunc {
case "matchit": case "matchit":
...@@ -488,7 +488,7 @@ func TestAllMatches(t *testing.T) { ...@@ -488,7 +488,7 @@ func TestAllMatches(t *testing.T) {
result = make([]string, len(c.input) + 1); result = make([]string, len(c.input) + 1);
b := strings.Bytes(c.input); b := strings.Bytes(c.input);
i := 0; i := 0;
for j, match := range re.AllMatches(b, c.n) { for _, match := range re.AllMatches(b, c.n) {
result[i] = string(match); result[i] = string(match);
i++; i++;
} }
......
...@@ -868,7 +868,7 @@ func (re *Regexp) ReplaceAllString(src, repl string) string { ...@@ -868,7 +868,7 @@ func (re *Regexp) ReplaceAllString(src, repl string) string {
lastMatchEnd = a[1]; lastMatchEnd = a[1];
// Advance past this match; always advance at least one character. // Advance past this match; always advance at least one character.
rune, width := utf8.DecodeRuneInString(src[searchPos:len(src)]); _, width := utf8.DecodeRuneInString(src[searchPos:len(src)]);
if searchPos + width > a[1] { if searchPos + width > a[1] {
searchPos += width; searchPos += width;
} else if searchPos + 1 > a[1] { } else if searchPos + 1 > a[1] {
...@@ -912,7 +912,7 @@ func (re *Regexp) ReplaceAll(src, repl []byte) []byte { ...@@ -912,7 +912,7 @@ func (re *Regexp) ReplaceAll(src, repl []byte) []byte {
lastMatchEnd = a[1]; lastMatchEnd = a[1];
// Advance past this match; always advance at least one character. // Advance past this match; always advance at least one character.
rune, width := utf8.DecodeRune(src[searchPos:len(src)]); _, width := utf8.DecodeRune(src[searchPos:len(src)]);
if searchPos + width > a[1] { if searchPos + width > a[1] {
searchPos += width; searchPos += width;
} else if searchPos + 1 > a[1] { } else if searchPos + 1 > a[1] {
......
...@@ -92,7 +92,7 @@ func (client *Client) input() { ...@@ -92,7 +92,7 @@ func (client *Client) input() {
// Terminate pending calls. // Terminate pending calls.
client.mutex.Lock(); client.mutex.Lock();
client.shutdown = err; client.shutdown = err;
for seq, call := range client.pending { for _, call := range client.pending {
call.Error = err; call.Error = err;
_ = call.Done <- call; // do not block _ = call.Done <- call; // do not block
} }
......
...@@ -170,7 +170,7 @@ var server = &serverType{ serviceMap: make(map[string] *service) } ...@@ -170,7 +170,7 @@ var server = &serverType{ serviceMap: make(map[string] *service) }
// Is this a publicly vislble - upper case - name? // Is this a publicly vislble - upper case - name?
func isPublic(name string) bool { func isPublic(name string) bool {
rune, wid_ := utf8.DecodeRuneInString(name); rune, _ := utf8.DecodeRuneInString(name);
return unicode.IsUpper(rune) return unicode.IsUpper(rune)
} }
...@@ -354,7 +354,7 @@ func (server *serverType) input(conn io.ReadWriteCloser) { ...@@ -354,7 +354,7 @@ func (server *serverType) input(conn io.ReadWriteCloser) {
func (server *serverType) accept(lis net.Listener) { func (server *serverType) accept(lis net.Listener) {
for { for {
conn, addr, err := lis.Accept(); conn, _, err := lis.Accept();
if err != nil { if err != nil {
log.Exit("rpc.Serve: accept:", err.String()); // TODO(r): exit? log.Exit("rpc.Serve: accept:", err.String()); // TODO(r): exit?
} }
...@@ -399,7 +399,7 @@ func serveHTTP(c *http.Conn, req *http.Request) { ...@@ -399,7 +399,7 @@ func serveHTTP(c *http.Conn, req *http.Request) {
io.WriteString(c, "405 must CONNECT to " + rpcPath + "\n"); io.WriteString(c, "405 must CONNECT to " + rpcPath + "\n");
return; return;
} }
conn, buf, err := c.Hijack(); conn, _, err := c.Hijack();
if err != nil { if err != nil {
log.Stderr("rpc hijacking ", c.RemoteAddr, ": ", err.String()); log.Stderr("rpc hijacking ", c.RemoteAddr, ": ", err.String());
return; return;
......
...@@ -60,7 +60,7 @@ var itob64tests = []itob64Test { ...@@ -60,7 +60,7 @@ var itob64tests = []itob64Test {
} }
func TestItoa(t *testing.T) { func TestItoa(t *testing.T) {
for i, test := range itob64tests { for _, test := range itob64tests {
s := Itob64(test.in, test.base); s := Itob64(test.in, test.base);
if s != test.out { if s != test.out {
t.Errorf("Itob64(%v, %v) = %v want %v\n", t.Errorf("Itob64(%v, %v) = %v want %v\n",
...@@ -140,7 +140,7 @@ var uitob64tests = []uitob64Test { ...@@ -140,7 +140,7 @@ var uitob64tests = []uitob64Test {
} }
func TestUitoa(t *testing.T) { func TestUitoa(t *testing.T) {
for i, test := range uitob64tests { for _, test := range uitob64tests {
s := Uitob64(test.in, test.base); s := Uitob64(test.in, test.base);
if s != test.out { if s != test.out {
t.Errorf("Uitob64(%v, %v) = %v want %v\n", t.Errorf("Uitob64(%v, %v) = %v want %v\n",
......
...@@ -157,7 +157,7 @@ func Map(mapping func(rune int) int, s string) string { ...@@ -157,7 +157,7 @@ func Map(mapping func(rune int) int, s string) string {
maxbytes := len(s); // length of b maxbytes := len(s); // length of b
nbytes := 0; // number of bytes encoded in b nbytes := 0; // number of bytes encoded in b
b := make([]byte, maxbytes); b := make([]byte, maxbytes);
for i, c := range s { for _, c := range s {
rune := mapping(c); rune := mapping(c);
wid := 1; wid := 1;
if rune >= utf8.RuneSelf { if rune >= utf8.RuneSelf {
...@@ -196,8 +196,8 @@ func Title(s string) string { ...@@ -196,8 +196,8 @@ func Title(s string) string {
// removed, as defined by Unicode. // removed, as defined by Unicode.
func TrimSpace(s string) string { func TrimSpace(s string) string {
start, end := 0, len(s); start, end := 0, len(s);
for wid := 0; start < end; start += wid { for start < end {
wid = 1; wid := 1;
rune := int(s[start]); rune := int(s[start]);
if rune >= utf8.RuneSelf { if rune >= utf8.RuneSelf {
rune, wid = utf8.DecodeRuneInString(s[start:end]) rune, wid = utf8.DecodeRuneInString(s[start:end])
...@@ -205,9 +205,10 @@ func TrimSpace(s string) string { ...@@ -205,9 +205,10 @@ func TrimSpace(s string) string {
if !unicode.IsSpace(rune) { if !unicode.IsSpace(rune) {
break; break;
} }
start += wid;
} }
for wid := 0; start < end; end -= wid { for start < end {
wid = 1; wid := 1;
rune := int(s[end-1]); rune := int(s[end-1]);
if rune >= utf8.RuneSelf { if rune >= utf8.RuneSelf {
// Back up carefully looking for beginning of rune. Mustn't pass start. // Back up carefully looking for beginning of rune. Mustn't pass start.
...@@ -221,6 +222,7 @@ func TrimSpace(s string) string { ...@@ -221,6 +222,7 @@ func TrimSpace(s string) string {
if !unicode.IsSpace(rune) { if !unicode.IsSpace(rune) {
break; break;
} }
end -= wid;
} }
return s[start:end]; return s[start:end];
} }
......
...@@ -66,7 +66,7 @@ var lastIndexTests = []IndexTest { ...@@ -66,7 +66,7 @@ var lastIndexTests = []IndexTest {
// Execute f on each test case. funcName should be the name of f; it's used // Execute f on each test case. funcName should be the name of f; it's used
// in failure reports. // in failure reports.
func runIndexTests(t *testing.T, f func(s, sep string) int, funcName string, testCases []IndexTest) { func runIndexTests(t *testing.T, f func(s, sep string) int, funcName string, testCases []IndexTest) {
for i,test := range testCases { for _, test := range testCases {
actual := f(test.s, test.sep); actual := f(test.s, test.sep);
if actual != test.out { if actual != test.out {
t.Errorf("%s(%q,%q) = %v; want %v", funcName, test.s, test.sep, actual, test.out); t.Errorf("%s(%q,%q) = %v; want %v", funcName, test.s, test.sep, actual, test.out);
...@@ -149,7 +149,7 @@ type StringTest struct { ...@@ -149,7 +149,7 @@ type StringTest struct {
// Execute f on each test case. funcName should be the name of f; it's used // Execute f on each test case. funcName should be the name of f; it's used
// in failure reports. // in failure reports.
func runStringTests(t *testing.T, f func(string) string, funcName string, testCases []StringTest) { func runStringTests(t *testing.T, f func(string) string, funcName string, testCases []StringTest) {
for i, tc := range testCases { for _, tc := range testCases {
actual := f(tc.in); actual := f(tc.in);
if actual != tc.out { if actual != tc.out {
t.Errorf("%s(%q) = %q; want %q", funcName, tc.in, actual, tc.out); t.Errorf("%s(%q) = %q; want %q", funcName, tc.in, actual, tc.out);
...@@ -237,8 +237,8 @@ func equal(m string, s1, s2 string, t *testing.T) bool { ...@@ -237,8 +237,8 @@ func equal(m string, s1, s2 string, t *testing.T) bool {
if i > len(e2) { if i > len(e2) {
break break
} }
r1, w := utf8.DecodeRuneInString(c1); r1, _ := utf8.DecodeRuneInString(c1);
r2, w := utf8.DecodeRuneInString(e2[i]); r2, _ := utf8.DecodeRuneInString(e2[i]);
if r1 != r2 { if r1 != r2 {
t.Errorf("%s diff at %d: U+%04X U+%04X", m, i, r1, r2) t.Errorf("%s diff at %d: U+%04X U+%04X", m, i, r1, r2)
} }
......
...@@ -85,7 +85,7 @@ func SetNonblock(fd int, nonblocking bool) (errno int) { ...@@ -85,7 +85,7 @@ func SetNonblock(fd int, nonblocking bool) (errno int) {
} else { } else {
flag &= ^O_NONBLOCK; flag &= ^O_NONBLOCK;
} }
flag, err = fcntl(fd, F_SETFL, flag); _, err = fcntl(fd, F_SETFL, flag);
return err; return err;
} }
...@@ -133,7 +133,7 @@ func forkAndExecInChild(argv0 *byte, argv []*byte, envv []*byte, traceme bool, d ...@@ -133,7 +133,7 @@ func forkAndExecInChild(argv0 *byte, argv []*byte, envv []*byte, traceme bool, d
// Enable tracing if requested. // Enable tracing if requested.
if traceme { if traceme {
r1, r2, err1 = RawSyscall(SYS_PTRACE, uintptr(_PTRACE_TRACEME), 0, 0); _, _, err1 = RawSyscall(SYS_PTRACE, uintptr(_PTRACE_TRACEME), 0, 0);
if err1 != 0 { if err1 != 0 {
goto childerror; goto childerror;
} }
...@@ -141,7 +141,7 @@ func forkAndExecInChild(argv0 *byte, argv []*byte, envv []*byte, traceme bool, d ...@@ -141,7 +141,7 @@ func forkAndExecInChild(argv0 *byte, argv []*byte, envv []*byte, traceme bool, d
// Chdir // Chdir
if dir != nil { if dir != nil {
r1, r2, err1 = RawSyscall(SYS_CHDIR, uintptr(unsafe.Pointer(dir)), 0, 0); _, _, err1 = RawSyscall(SYS_CHDIR, uintptr(unsafe.Pointer(dir)), 0, 0);
if err1 != 0 { if err1 != 0 {
goto childerror; goto childerror;
} }
...@@ -151,7 +151,7 @@ func forkAndExecInChild(argv0 *byte, argv []*byte, envv []*byte, traceme bool, d ...@@ -151,7 +151,7 @@ func forkAndExecInChild(argv0 *byte, argv []*byte, envv []*byte, traceme bool, d
// so that pass 2 won't stomp on an fd it needs later. // so that pass 2 won't stomp on an fd it needs later.
nextfd = int(len(fd)); nextfd = int(len(fd));
if pipe < nextfd { if pipe < nextfd {
r1, r2, err1 = RawSyscall(SYS_DUP2, uintptr(pipe), uintptr(nextfd), 0); _, _, err1 = RawSyscall(SYS_DUP2, uintptr(pipe), uintptr(nextfd), 0);
if err1 != 0 { if err1 != 0 {
goto childerror; goto childerror;
} }
...@@ -161,7 +161,7 @@ func forkAndExecInChild(argv0 *byte, argv []*byte, envv []*byte, traceme bool, d ...@@ -161,7 +161,7 @@ func forkAndExecInChild(argv0 *byte, argv []*byte, envv []*byte, traceme bool, d
} }
for i = 0; i < len(fd); i++ { for i = 0; i < len(fd); i++ {
if fd[i] >= 0 && fd[i] < int(i) { if fd[i] >= 0 && fd[i] < int(i) {
r1, r2, err1 = RawSyscall(SYS_DUP2, uintptr(fd[i]), uintptr(nextfd), 0); _, _, err1 = RawSyscall(SYS_DUP2, uintptr(fd[i]), uintptr(nextfd), 0);
if err1 != 0 { if err1 != 0 {
goto childerror; goto childerror;
} }
...@@ -183,7 +183,7 @@ func forkAndExecInChild(argv0 *byte, argv []*byte, envv []*byte, traceme bool, d ...@@ -183,7 +183,7 @@ func forkAndExecInChild(argv0 *byte, argv []*byte, envv []*byte, traceme bool, d
if fd[i] == int(i) { if fd[i] == int(i) {
// dup2(i, i) won't clear close-on-exec flag on Linux, // dup2(i, i) won't clear close-on-exec flag on Linux,
// probably not elsewhere either. // probably not elsewhere either.
r1, r2, err1 = RawSyscall(SYS_FCNTL, uintptr(fd[i]), F_SETFD, 0); _, _, err1 = RawSyscall(SYS_FCNTL, uintptr(fd[i]), F_SETFD, 0);
if err1 != 0 { if err1 != 0 {
goto childerror; goto childerror;
} }
...@@ -191,7 +191,7 @@ func forkAndExecInChild(argv0 *byte, argv []*byte, envv []*byte, traceme bool, d ...@@ -191,7 +191,7 @@ func forkAndExecInChild(argv0 *byte, argv []*byte, envv []*byte, traceme bool, d
} }
// The new fd is created NOT close-on-exec, // The new fd is created NOT close-on-exec,
// which is exactly what we want. // which is exactly what we want.
r1, r2, err1 = RawSyscall(SYS_DUP2, uintptr(fd[i]), uintptr(i), 0); _, _, err1 = RawSyscall(SYS_DUP2, uintptr(fd[i]), uintptr(i), 0);
if err1 != 0 { if err1 != 0 {
goto childerror; goto childerror;
} }
...@@ -206,7 +206,7 @@ func forkAndExecInChild(argv0 *byte, argv []*byte, envv []*byte, traceme bool, d ...@@ -206,7 +206,7 @@ func forkAndExecInChild(argv0 *byte, argv []*byte, envv []*byte, traceme bool, d
} }
// Time to exec. // Time to exec.
r1, r2, err1 = RawSyscall(SYS_EXECVE, _, _, err1 = RawSyscall(SYS_EXECVE,
uintptr(unsafe.Pointer(argv0)), uintptr(unsafe.Pointer(argv0)),
uintptr(unsafe.Pointer(&argv[0])), uintptr(unsafe.Pointer(&argv[0])),
uintptr(unsafe.Pointer(&envv[0]))); uintptr(unsafe.Pointer(&envv[0])));
...@@ -287,9 +287,9 @@ func forkExec(argv0 string, argv []string, envv []string, traceme bool, dir stri ...@@ -287,9 +287,9 @@ func forkExec(argv0 string, argv []string, envv []string, traceme bool, dir stri
// Child failed; wait for it to exit, to make sure // Child failed; wait for it to exit, to make sure
// the zombies don't accumulate. // the zombies don't accumulate.
pid1, err1 := Wait4(pid, &wstatus, 0, nil); _, err1 := Wait4(pid, &wstatus, 0, nil);
for err1 == EINTR { for err1 == EINTR {
pid1, err1 = Wait4(pid, &wstatus, 0, nil); _, err1 = Wait4(pid, &wstatus, 0, nil);
} }
return 0, err return 0, err
} }
...@@ -314,7 +314,7 @@ func PtraceForkExec(argv0 string, argv []string, envv []string, dir string, fd [ ...@@ -314,7 +314,7 @@ func PtraceForkExec(argv0 string, argv []string, envv []string, dir string, fd [
// Ordinary exec. // Ordinary exec.
func Exec(argv0 string, argv []string, envv []string) (err int) { func Exec(argv0 string, argv []string, envv []string) (err int) {
r1, r2, err1 := RawSyscall(SYS_EXECVE, _, _, err1 := RawSyscall(SYS_EXECVE,
uintptr(unsafe.Pointer(StringBytePtr(argv0))), uintptr(unsafe.Pointer(StringBytePtr(argv0))),
uintptr(unsafe.Pointer(&StringArrayPtr(argv)[0])), uintptr(unsafe.Pointer(&StringArrayPtr(argv)[0])),
uintptr(unsafe.Pointer(&StringArrayPtr(envv)[0]))); uintptr(unsafe.Pointer(&StringArrayPtr(envv)[0])));
......
...@@ -297,7 +297,7 @@ func TestAll(t *testing.T) { ...@@ -297,7 +297,7 @@ func TestAll(t *testing.T) {
s.false = false; s.false = false;
var buf bytes.Buffer; var buf bytes.Buffer;
for i, test := range tests { for _, test := range tests {
buf.Reset(); buf.Reset();
tmpl, err := Parse(test.in, formatters); tmpl, err := Parse(test.in, formatters);
if err != nil { if err != nil {
......
...@@ -13,7 +13,7 @@ import ( ...@@ -13,7 +13,7 @@ import (
// Seconds reports the number of seconds since the Unix epoch, // Seconds reports the number of seconds since the Unix epoch,
// January 1, 1970 00:00:00 UTC. // January 1, 1970 00:00:00 UTC.
func Seconds() int64 { func Seconds() int64 {
sec, nsec, err := os.Time(); sec, _, err := os.Time();
if err != nil { if err != nil {
panic("time: os.Time: ", err.String()); panic("time: os.Time: ", err.String());
} }
......
...@@ -132,7 +132,7 @@ func parseinfo(bytes []byte) (zt []zonetime, ok bool) { ...@@ -132,7 +132,7 @@ func parseinfo(bytes []byte) (zt []zonetime, ok bool) {
abbrev := d.read(n[NChar]); abbrev := d.read(n[NChar]);
// Leap-second time pairs // Leap-second time pairs
leapdata := data{d.read(n[NLeap]*8), false}; d.read(n[NLeap]*8);
// Whether tx times associated with local time types // Whether tx times associated with local time types
// are specified as standard time or wall time. // are specified as standard time or wall time.
......
...@@ -104,12 +104,12 @@ var testLetter = []int { ...@@ -104,12 +104,12 @@ var testLetter = []int {
} }
func TestDigit(t *testing.T) { func TestDigit(t *testing.T) {
for i, r := range testDigit { for _, r := range testDigit {
if !IsDigit(r) { if !IsDigit(r) {
t.Errorf("IsDigit(U+%04X) = false, want true\n", r); t.Errorf("IsDigit(U+%04X) = false, want true\n", r);
} }
} }
for i, r := range testLetter { for _, r := range testLetter {
if IsDigit(r) { if IsDigit(r) {
t.Errorf("IsDigit(U+%04X) = true, want false\n", r); t.Errorf("IsDigit(U+%04X) = true, want false\n", r);
} }
......
...@@ -54,7 +54,7 @@ const ( ...@@ -54,7 +54,7 @@ const (
func Is(ranges []Range, rune int) bool { func Is(ranges []Range, rune int) bool {
// common case: rune is ASCII or Latin-1 // common case: rune is ASCII or Latin-1
if rune < 0x100 { if rune < 0x100 {
for i, r := range ranges { for _, r := range ranges {
if rune > r.Hi { if rune > r.Hi {
continue; continue;
} }
...@@ -150,7 +150,7 @@ func To(_case int, rune int) int { ...@@ -150,7 +150,7 @@ func To(_case int, rune int) int {
// The characters at even offsets from the beginning of the // The characters at even offsets from the beginning of the
// sequence are upper case; the ones at odd offsets are lower. // sequence are upper case; the ones at odd offsets are lower.
// The correct mapping can be done by clearing or setting the low // The correct mapping can be done by clearing or setting the low
// bit in the sequence offset. // bit in the sequence offset.
// The constants UpperCase and TitleCase are even while LowerCase // The constants UpperCase and TitleCase are even while LowerCase
// is odd so we take the low bit from _case. // is odd so we take the low bit from _case.
return r.Lo + ((rune - r.Lo)&^1 | _case&1); return r.Lo + ((rune - r.Lo)&^1 | _case&1);
......
...@@ -214,17 +214,17 @@ var caseTest = []caseT { ...@@ -214,17 +214,17 @@ var caseTest = []caseT {
} }
func TestIsLetter(t *testing.T) { func TestIsLetter(t *testing.T) {
for i, r := range upperTest { for _, r := range upperTest {
if !IsLetter(r) { if !IsLetter(r) {
t.Errorf("IsLetter(U+%04X) = false, want true\n", r); t.Errorf("IsLetter(U+%04X) = false, want true\n", r);
} }
} }
for i, r := range letterTest { for _, r := range letterTest {
if !IsLetter(r) { if !IsLetter(r) {
t.Errorf("IsLetter(U+%04X) = false, want true\n", r); t.Errorf("IsLetter(U+%04X) = false, want true\n", r);
} }
} }
for i, r := range notletterTest { for _, r := range notletterTest {
if IsLetter(r) { if IsLetter(r) {
t.Errorf("IsLetter(U+%04X) = true, want false\n", r); t.Errorf("IsLetter(U+%04X) = true, want false\n", r);
} }
...@@ -232,17 +232,17 @@ func TestIsLetter(t *testing.T) { ...@@ -232,17 +232,17 @@ func TestIsLetter(t *testing.T) {
} }
func TestIsUpper(t *testing.T) { func TestIsUpper(t *testing.T) {
for i, r := range upperTest { for _, r := range upperTest {
if !IsUpper(r) { if !IsUpper(r) {
t.Errorf("IsUpper(U+%04X) = false, want true\n", r); t.Errorf("IsUpper(U+%04X) = false, want true\n", r);
} }
} }
for i, r := range notupperTest { for _, r := range notupperTest {
if IsUpper(r) { if IsUpper(r) {
t.Errorf("IsUpper(U+%04X) = true, want false\n", r); t.Errorf("IsUpper(U+%04X) = true, want false\n", r);
} }
} }
for i, r := range notletterTest { for _, r := range notletterTest {
if IsUpper(r) { if IsUpper(r) {
t.Errorf("IsUpper(U+%04X) = true, want false\n", r); t.Errorf("IsUpper(U+%04X) = true, want false\n", r);
} }
...@@ -262,7 +262,7 @@ func caseString(c int) string { ...@@ -262,7 +262,7 @@ func caseString(c int) string {
} }
func TestTo(t *testing.T) { func TestTo(t *testing.T) {
for i, c := range caseTest { for _, c := range caseTest {
r := To(c.cas, c.in); r := To(c.cas, c.in);
if c.out != r { if c.out != r {
t.Errorf("To(U+%04X, %s) = U+%04X want U+%04X\n", c.in, caseString(c.cas), r, c.out); t.Errorf("To(U+%04X, %s) = U+%04X want U+%04X\n", c.in, caseString(c.cas), r, c.out);
...@@ -271,7 +271,7 @@ func TestTo(t *testing.T) { ...@@ -271,7 +271,7 @@ func TestTo(t *testing.T) {
} }
func TestToUpperCase(t *testing.T) { func TestToUpperCase(t *testing.T) {
for i, c := range caseTest { for _, c := range caseTest {
if c.cas != UpperCase { if c.cas != UpperCase {
continue continue
} }
...@@ -283,7 +283,7 @@ func TestToUpperCase(t *testing.T) { ...@@ -283,7 +283,7 @@ func TestToUpperCase(t *testing.T) {
} }
func TestToLowerCase(t *testing.T) { func TestToLowerCase(t *testing.T) {
for i, c := range caseTest { for _, c := range caseTest {
if c.cas != LowerCase { if c.cas != LowerCase {
continue continue
} }
...@@ -295,7 +295,7 @@ func TestToLowerCase(t *testing.T) { ...@@ -295,7 +295,7 @@ func TestToLowerCase(t *testing.T) {
} }
func TestToTitleCase(t *testing.T) { func TestToTitleCase(t *testing.T) {
for i, c := range caseTest { for _, c := range caseTest {
if c.cas != TitleCase { if c.cas != TitleCase {
continue continue
} }
......
...@@ -174,7 +174,7 @@ func TestScripts(t *testing.T) { ...@@ -174,7 +174,7 @@ func TestScripts(t *testing.T) {
for k := range Scripts { for k := range Scripts {
notTested[k] = true notTested[k] = true
} }
for i, test := range inTest { for _, test := range inTest {
if _, ok := Scripts[test.script]; !ok { if _, ok := Scripts[test.script]; !ok {
t.Fatal(test.script, "not a known script") t.Fatal(test.script, "not a known script")
} }
...@@ -183,7 +183,7 @@ func TestScripts(t *testing.T) { ...@@ -183,7 +183,7 @@ func TestScripts(t *testing.T) {
} }
notTested[test.script] = false, false notTested[test.script] = false, false
} }
for i, test := range outTest { for _, test := range outTest {
if Is(Scripts[test.script], test.rune) { if Is(Scripts[test.script], test.rune) {
t.Errorf("IsScript(%#x, %s) = true, want false\n", test.rune, test.script); t.Errorf("IsScript(%#x, %s) = true, want false\n", test.rune, test.script);
} }
...@@ -198,7 +198,7 @@ func TestCategories(t *testing.T) { ...@@ -198,7 +198,7 @@ func TestCategories(t *testing.T) {
for k := range Categories { for k := range Categories {
notTested[k] = true notTested[k] = true
} }
for i, test := range inCategoryTest { for _, test := range inCategoryTest {
if _, ok := Categories[test.script]; !ok { if _, ok := Categories[test.script]; !ok {
t.Fatal(test.script, "not a known category") t.Fatal(test.script, "not a known category")
} }
...@@ -217,7 +217,7 @@ func TestProperties(t *testing.T) { ...@@ -217,7 +217,7 @@ func TestProperties(t *testing.T) {
for k := range Properties { for k := range Properties {
notTested[k] = true notTested[k] = true
} }
for i, test := range inPropTest { for _, test := range inPropTest {
if _, ok := Properties[test.script]; !ok { if _, ok := Properties[test.script]; !ok {
t.Fatal(test.script, "not a known prop") t.Fatal(test.script, "not a known prop")
} }
......
...@@ -187,13 +187,13 @@ func decodeRuneInStringInternal(s string) (rune, size int, short bool) { ...@@ -187,13 +187,13 @@ func decodeRuneInStringInternal(s string) (rune, size int, short bool) {
// FullRune reports whether the bytes in p begin with a full UTF-8 encoding of a rune. // FullRune reports whether the bytes in p begin with a full UTF-8 encoding of a rune.
// An invalid encoding is considered a full Rune since it will convert as a width-1 error rune. // An invalid encoding is considered a full Rune since it will convert as a width-1 error rune.
func FullRune(p []byte) bool { func FullRune(p []byte) bool {
rune, size, short := decodeRuneInternal(p); _, _, short := decodeRuneInternal(p);
return !short return !short
} }
// FullRuneInString is like FullRune but its input is a string. // FullRuneInString is like FullRune but its input is a string.
func FullRuneInString(s string) bool { func FullRuneInString(s string) bool {
rune, size, short := decodeRuneInStringInternal(s); _, _, short := decodeRuneInStringInternal(s);
return !short return !short
} }
...@@ -265,7 +265,7 @@ func RuneCount(p []byte) int { ...@@ -265,7 +265,7 @@ func RuneCount(p []byte) int {
if p[i] < RuneSelf { if p[i] < RuneSelf {
i++; i++;
} else { } else {
rune, size := DecodeRune(p[i:len(p)]); _, size := DecodeRune(p[i:len(p)]);
i += size; i += size;
} }
} }
...@@ -276,12 +276,12 @@ func RuneCount(p []byte) int { ...@@ -276,12 +276,12 @@ func RuneCount(p []byte) int {
func RuneCountInString(s string) int { func RuneCountInString(s string) int {
ei := len(s); ei := len(s);
i := 0; i := 0;
n := 0; var n int;
for n = 0; i < ei; n++ { for n = 0; i < ei; n++ {
if s[i] < RuneSelf { if s[i] < RuneSelf {
i++; i++;
} else { } else {
rune, size, short := decodeRuneInStringInternal(s[i:ei]); _, size, _ := decodeRuneInStringInternal(s[i:ei]);
i += size; i += size;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment