Skip to content

Commit 4ad2637

Browse files
committed
Improve iota constants and go:generate comments
1 parent 5a883df commit 4ad2637

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

datatype.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package websocket
22

33
// DataType represents the Opcode of a WebSocket data frame.
4-
//go:generate go run golang.org/x/tools/cmd/stringer -type=DataType
54
type DataType int
5+
//go:generate go run golang.org/x/tools/cmd/stringer -type=DataType
66

77
// DataType constants.
88
const (

opcode.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
package websocket
22

33
// opcode represents a WebSocket Opcode.
4-
//go:generate go run golang.org/x/tools/cmd/stringer -type=opcode
54
type opcode int
5+
//go:generate go run golang.org/x/tools/cmd/stringer -type=opcode
66

77
// opcode constants.
88
const (
99
opContinuation opcode = iota
1010
opText
1111
opBinary
1212
// 3 - 7 are reserved for further non-control frames.
13-
opClose opcode = 8 + iota - 3
13+
_
14+
_
15+
_
16+
_
17+
_
18+
opClose
1419
opPing
1520
opPong
1621
// 11-16 are reserved for further control frames.

statuscode.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
)
1212

1313
// StatusCode represents a WebSocket status code.
14-
//go:generate go run golang.org/x/tools/cmd/stringer -type=StatusCode
1514
type StatusCode int
15+
//go:generate go run golang.org/x/tools/cmd/stringer -type=StatusCode
1616

1717
// These codes were retrieved from:
1818
// https://www.iana.org/assignments/websocket/websocket.xhtml#close-code-number
@@ -21,8 +21,8 @@ const (
2121
StatusGoingAway
2222
StatusProtocolError
2323
StatusUnsupportedData
24-
// 1004 is reserved.
25-
StatusNoStatusRcvd StatusCode = 1005 + iota - 4
24+
_ // 1004 is reserved.
25+
StatusNoStatusRcvd
2626
StatusAbnormalClosure
2727
StatusInvalidFramePayloadData
2828
StatusPolicyViolation

0 commit comments

Comments
 (0)