Skip to content

Commit a9dd6e8

Browse files
Steven Scottgaryburd
authored andcommitted
miscellaneous cleanup
- Add Go 1.11 to Travis config - Use short variable declarations where possible. - Remove unnecessary build tags after move to Go 1.7 min version. - Simplify composite literals. - Remove unused fields (err in PerparedMessage) - Fix errors reported by golint and goword.
1 parent ceae452 commit a9dd6e8

File tree

8 files changed

+9
-18
lines changed

8 files changed

+9
-18
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ matrix:
77
- go: 1.8.x
88
- go: 1.9.x
99
- go: 1.10.x
10+
- go: 1.11.x
1011
- go: tip
1112
allow_failures:
1213
- go: tip

client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ var DefaultDialer = &Dialer{
133133
}
134134

135135
// nilDialer is dialer to use when receiver is nil.
136-
var nilDialer Dialer = *DefaultDialer
136+
var nilDialer = *DefaultDialer
137137

138138
// DialContext creates a new client connection. Use requestHeader to specify the
139139
// origin (Origin), subprotocols (Sec-WebSocket-Protocol) and cookies (Cookie).

conn_broadcast_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build go1.7
6-
75
package websocket
86

97
import (

mask_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// this source code is governed by a BSD-style license that can be found in the
33
// LICENSE file.
44

5-
// Require 1.7 for sub-bencmarks
6-
// +build go1.7,!appengine
5+
// !appengine
76

87
package websocket
98

prepared.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
type PreparedMessage struct {
2020
messageType int
2121
data []byte
22-
err error
2322
mu sync.Mutex
2423
frames map[prepareKey]*preparedFrame
2524
}

server.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"bufio"
99
"errors"
1010
"io"
11-
"net"
1211
"net/http"
1312
"net/url"
1413
"strings"
@@ -171,17 +170,12 @@ func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeade
171170
}
172171
}
173172

174-
var (
175-
netConn net.Conn
176-
err error
177-
)
178-
179173
h, ok := w.(http.Hijacker)
180174
if !ok {
181175
return u.returnError(w, r, http.StatusInternalServerError, "websocket: response does not implement http.Hijacker")
182176
}
183177
var brw *bufio.ReadWriter
184-
netConn, brw, err = h.Hijack()
178+
netConn, brw, err := h.Hijack()
185179
if err != nil {
186180
return u.returnError(w, r, http.StatusInternalServerError, err.Error())
187181
}
@@ -331,7 +325,7 @@ func IsWebSocketUpgrade(r *http.Request) bool {
331325
tokenListContainsValue(r.Header, "Upgrade", "websocket")
332326
}
333327

334-
// bufioReader size returns the size of a bufio.Reader.
328+
// bufioReaderSize size returns the size of a bufio.Reader.
335329
func bufioReaderSize(originalReader io.Reader, br *bufio.Reader) int {
336330
// This code assumes that peek on a reset reader returns
337331
// bufio.Reader.buf[:0].

server_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ var checkSameOriginTests = []struct {
5858
ok bool
5959
r *http.Request
6060
}{
61-
{false, &http.Request{Host: "example.org", Header: map[string][]string{"Origin": []string{"https://other.org"}}}},
62-
{true, &http.Request{Host: "example.org", Header: map[string][]string{"Origin": []string{"https://example.org"}}}},
63-
{true, &http.Request{Host: "Example.org", Header: map[string][]string{"Origin": []string{"https://example.org"}}}},
61+
{false, &http.Request{Host: "example.org", Header: map[string][]string{"Origin": {"https://other.org"}}}},
62+
{true, &http.Request{Host: "example.org", Header: map[string][]string{"Origin": {"https://example.org"}}}},
63+
{true, &http.Request{Host: "Example.org", Header: map[string][]string{"Origin": {"https://example.org"}}}},
6464
}
6565

6666
func TestCheckSameOrigin(t *testing.T) {

util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ headers:
178178
return false
179179
}
180180

181-
// parseExtensiosn parses WebSocket extensions from a header.
181+
// parseExtensions parses WebSocket extensions from a header.
182182
func parseExtensions(header http.Header) []map[string]string {
183183
// From RFC 6455:
184184
//

0 commit comments

Comments
 (0)