Commit 3395f6c7 authored by Matt Holt's avatar Matt Holt

Merge pull request #698 from buddhamagnet/master

Correct unused assignments
parents 7271b571 61cf8b79
...@@ -116,7 +116,7 @@ func TestRedirPlaintextHost(t *testing.T) { ...@@ -116,7 +116,7 @@ func TestRedirPlaintextHost(t *testing.T) {
// browsers can infer a default port from scheme, so make sure the port // browsers can infer a default port from scheme, so make sure the port
// doesn't get added in explicitly for default ports like 443 for https. // doesn't get added in explicitly for default ports like 443 for https.
cfg = redirPlaintextHost(server.Config{Host: "example.com", Port: "443"}) cfg = redirPlaintextHost(server.Config{Host: "example.com", Port: "443"})
handler, ok = cfg.Middleware[0](nil).(redirect.Redirect) handler, _ = cfg.Middleware[0](nil).(redirect.Redirect)
if actual, expected := handler.Rules[0].To, "https://{host}{uri}"; actual != expected { if actual, expected := handler.Rules[0].To, "https://{host}{uri}"; actual != expected {
t.Errorf("(Default Port) Expected redirect rule to be to URL '%s' but is actually to '%s'", expected, actual) t.Errorf("(Default Port) Expected redirect rule to be to URL '%s' but is actually to '%s'", expected, actual)
} }
......
...@@ -40,7 +40,7 @@ func TestErrors(t *testing.T) { ...@@ -40,7 +40,7 @@ func TestErrors(t *testing.T) {
if len(c.Startup) == 0 { if len(c.Startup) == 0 {
t.Fatal("Expected 1 startup function, had 0") t.Fatal("Expected 1 startup function, had 0")
} }
err = c.Startup[0]() c.Startup[0]()
if myHandler.Log == nil { if myHandler.Log == nil {
t.Error("Expected Log to be non-nil after startup because Debug is not enabled") t.Error("Expected Log to be non-nil after startup because Debug is not enabled")
} }
......
...@@ -62,7 +62,7 @@ func webSocketParse(c *Controller) ([]websocket.Config, error) { ...@@ -62,7 +62,7 @@ func webSocketParse(c *Controller) ([]websocket.Config, error) {
} }
// Okay, check again for optional block // Okay, check again for optional block
hadBlock, err = optionalBlock() _, err = optionalBlock()
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -131,7 +131,7 @@ func TestBrowseTemplate(t *testing.T) { ...@@ -131,7 +131,7 @@ func TestBrowseTemplate(t *testing.T) {
rec := httptest.NewRecorder() rec := httptest.NewRecorder()
code, err := b.ServeHTTP(rec, req) code, _ := b.ServeHTTP(rec, req)
if code != http.StatusOK { if code != http.StatusOK {
t.Fatalf("Wrong status, expected %d, got %d", http.StatusOK, code) t.Fatalf("Wrong status, expected %d, got %d", http.StatusOK, code)
} }
......
...@@ -113,7 +113,6 @@ func parseWindowsCommand(cmd string) []string { ...@@ -113,7 +113,6 @@ func parseWindowsCommand(cmd string) []string {
if len(part) > 0 { if len(part) > 0 {
parts = append(parts, part) parts = append(parts, part)
part = ""
} }
return parts return parts
......
...@@ -153,7 +153,6 @@ func (c Context) StripHTML(s string) string { ...@@ -153,7 +153,6 @@ func (c Context) StripHTML(s string) string {
if inTag { if inTag {
// false start // false start
buf.WriteString(s[tagStart:]) buf.WriteString(s[tagStart:])
inTag = false
} }
return buf.String() return buf.String()
} }
......
...@@ -149,7 +149,7 @@ func (rec *record) read(r io.Reader) (buf []byte, err error) { ...@@ -149,7 +149,7 @@ func (rec *record) read(r io.Reader) (buf []byte, err error) {
if len(rec.rbuf) < n { if len(rec.rbuf) < n {
rec.rbuf = make([]byte, n) rec.rbuf = make([]byte, n)
} }
if n, err = io.ReadFull(r, rec.rbuf[:n]); err != nil { if _, err = io.ReadFull(r, rec.rbuf[:n]); err != nil {
return return
} }
buf = rec.rbuf[:int(rec.h.ContentLength)] buf = rec.rbuf[:int(rec.h.ContentLength)]
......
...@@ -149,7 +149,7 @@ func sendFcgi(reqType int, fcgiParams map[string]string, data []byte, posts map[ ...@@ -149,7 +149,7 @@ func sendFcgi(reqType int, fcgiParams map[string]string, data []byte, posts map[
} }
defer resp.Body.Close() defer resp.Body.Close()
content, err = ioutil.ReadAll(resp.Body) content, _ = ioutil.ReadAll(resp.Body)
log.Println("c: send data length ≈", length, string(content)) log.Println("c: send data length ≈", length, string(content))
fcgi.Close() fcgi.Close()
...@@ -226,16 +226,11 @@ func DisabledTest(t *testing.T) { ...@@ -226,16 +226,11 @@ func DisabledTest(t *testing.T) {
log.Println("test:", "post data (more than 60KB)") log.Println("test:", "post data (more than 60KB)")
data := "" data := ""
length := 0
for i := 0x00; i < 0xff; i++ { for i := 0x00; i < 0xff; i++ {
v0 := strings.Repeat(string(i), 256) v0 := strings.Repeat(string(i), 256)
h := md5.New() h := md5.New()
io.WriteString(h, v0) io.WriteString(h, v0)
k0 := fmt.Sprintf("%x", h.Sum(nil)) k0 := fmt.Sprintf("%x", h.Sum(nil))
length += len(k0)
length += len(v0)
data += k0 + "=" + url.QueryEscape(v0) + "&" data += k0 + "=" + url.QueryEscape(v0) + "&"
} }
sendFcgi(0, fcgiParams, []byte(data), nil, nil) sendFcgi(0, fcgiParams, []byte(data), nil, nil)
......
...@@ -37,7 +37,7 @@ func TestInternal(t *testing.T) { ...@@ -37,7 +37,7 @@ func TestInternal(t *testing.T) {
} }
rec := httptest.NewRecorder() rec := httptest.NewRecorder()
code, err := im.ServeHTTP(rec, req) code, _ := im.ServeHTTP(rec, req)
if code != test.expectedCode { if code != test.expectedCode {
t.Errorf("Test %d: Expected status code %d for %s, but got %d", t.Errorf("Test %d: Expected status code %d for %s, but got %d",
......
...@@ -201,12 +201,12 @@ func TestParsers(t *testing.T) { ...@@ -201,12 +201,12 @@ func TestParsers(t *testing.T) {
} }
// invalid metadata // invalid metadata
if md, err = v.parser.Parse([]byte(v.testData[3])); err == nil { if _, err = v.parser.Parse([]byte(v.testData[3])); err == nil {
t.Fatalf("Expected error for invalid metadata for %v", v.name) t.Fatalf("Expected error for invalid metadata for %v", v.name)
} }
// front matter but no body // front matter but no body
if md, err = v.parser.Parse([]byte(v.testData[4])); err != nil { if _, err = v.parser.Parse([]byte(v.testData[4])); err != nil {
t.Fatalf("Unexpected error for valid metadata but no body for %v", v.name) t.Fatalf("Unexpected error for valid metadata but no body for %v", v.name)
} }
} }
......
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