浏览代码

Misc cleanup

- Fix lint warnings.
- Use standard comment format to mark deprecated identifiers.
- Remove redundant paragraph from doc.
Gary Burd 8 年之前
父节点
当前提交
92f772e4b3
共有 4 个文件被更改,包括 12 次插入12 次删除
  1. 0 5
      doc.go
  2. 8 3
      json.go
  3. 2 2
      server.go
  4. 2 2
      util.go

+ 0 - 5
doc.go

@@ -146,11 +146,6 @@
 //      CheckOrigin: func(r *http.Request) bool { return true },
 //  }
 //
-// We recommend the upgrader.Upgrade method to perform an upgrade
-// from an HTTP connection to a websocket connection. This method performs
-// origin policy checking using the CheckOrigin field associated with the
-// Upgrader instance.
-//
 // The deprecated package-level Upgrade function does not perform origin
 // checking. The application is responsible for checking the Origin header
 // before calling the Upgrade function.

+ 8 - 3
json.go

@@ -9,12 +9,14 @@ import (
 	"io"
 )
 
-// WriteJSON is deprecated, use c.WriteJSON instead.
+// WriteJSON writes the JSON encoding of v as a message.
+//
+// Deprecated: Use c.WriteJSON instead.
 func WriteJSON(c *Conn, v interface{}) error {
 	return c.WriteJSON(v)
 }
 
-// WriteJSON writes the JSON encoding of v to the connection.
+// WriteJSON writes the JSON encoding of v as a message.
 //
 // See the documentation for encoding/json Marshal for details about the
 // conversion of Go values to JSON.
@@ -31,7 +33,10 @@ func (c *Conn) WriteJSON(v interface{}) error {
 	return err2
 }
 
-// ReadJSON is deprecated, use c.ReadJSON instead.
+// ReadJSON reads the next JSON-encoded message from the connection and stores
+// it in the value pointed to by v.
+//
+// Deprecated: Use c.ReadJSON instead.
 func ReadJSON(c *Conn, v interface{}) error {
 	return c.ReadJSON(v)
 }

+ 2 - 2
server.go

@@ -228,10 +228,10 @@ func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeade
 	return c, nil
 }
 
-// Deprecated: Use websocket.Upgrader instead.
-//
 // Upgrade upgrades the HTTP server connection to the WebSocket protocol.
 //
+// Deprecated: Use websocket.Upgrader instead.
+//
 // Upgrade does not perform origin checking. The application is responsible for
 // checking the Origin header before calling Upgrade. An example implementation
 // of the same origin policy check is:

+ 2 - 2
util.go

@@ -111,14 +111,14 @@ func nextTokenOrQuoted(s string) (value string, rest string) {
 				case escape:
 					escape = false
 					p[j] = b
-					j += 1
+					j++
 				case b == '\\':
 					escape = true
 				case b == '"':
 					return string(p[:j]), s[i+1:]
 				default:
 					p[j] = b
-					j += 1
+					j++
 				}
 			}
 			return "", ""