Naming, layout and comments: descriptive full-word names, one item per line in wrapped calls and literals, and doc comments on exported names
Short and single-letter names in application code become full words (tests keep theirs). Wrapped calls, signatures and composite literals put one item per line, and one-line function bodies are expanded. Exported names and groups of constants get doc comments, and comments refer to the renamed identifiers.
This commit is contained in:
1 parent
043e307663
commit
465358609a
78 files changed
+2374
-1402
No files matched your search
@@ -17,9 +17,15 @@ import (
|
||||
func pipeClient(t *testing.T, h *Hub) (net.Conn, chan struct{}) {
|
||||
t.Helper()
|
||||
server, peer := net.Pipe()
|
||||
t.Cleanup(func() { server.Close(); peer.Close() })
|
||||
t.Cleanup(func() {
|
||||
server.Close()
|
||||
peer.Close()
|
||||
})
|
||||
done := make(chan struct{})
|
||||
go func() { h.ServeTCP(context.Background(), server); close(done) }()
|
||||
go func() {
|
||||
h.ServeTCP(context.Background(), server)
|
||||
close(done)
|
||||
}()
|
||||
peer.SetReadDeadline(time.Now().Add(time.Second))
|
||||
if _, err := bufio.NewReader(peer).ReadString('\n'); err != nil {
|
||||
t.Fatalf("welcome: %v", err)
|
||||
@@ -61,10 +67,13 @@ func TestShutdownNoClients(t *testing.T) {
|
||||
|
||||
// A ping that can't be sent within the pong timeout drops the client.
|
||||
func TestPingFailureDropsClient(t *testing.T) {
|
||||
h := NewHub(config.JSCServerWebSocket{
|
||||
PingInterval: 10 * time.Millisecond,
|
||||
PongTimeout: 20 * time.Millisecond,
|
||||
}, WithLogger(discardLog))
|
||||
h := NewHub(
|
||||
config.JSCServerWebSocket{
|
||||
PingInterval: 10 * time.Millisecond,
|
||||
PongTimeout: 20 * time.Millisecond,
|
||||
},
|
||||
WithLogger(discardLog),
|
||||
)
|
||||
_, done := pipeClient(t, h)
|
||||
|
||||
select {
|
||||
@@ -81,8 +90,12 @@ func TestMaxMessageSize(t *testing.T) {
|
||||
want int
|
||||
}{
|
||||
{config.JSCServerWebSocket{}, defaultMaxMessageSize},
|
||||
{config.JSCServerWebSocket{MaxMessageSize: -1}, defaultMaxMessageSize},
|
||||
{config.JSCServerWebSocket{MaxMessageSize: 100}, 100},
|
||||
{config.JSCServerWebSocket{
|
||||
MaxMessageSize: -1,
|
||||
}, defaultMaxMessageSize},
|
||||
{config.JSCServerWebSocket{
|
||||
MaxMessageSize: 100,
|
||||
}, 100},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
h := NewHub(tt.conf, WithLogger(discardLog))
|
||||
|
||||
Reference in new issue
Block a user