forked from mirror/websocket
Fix DefaultDialar value
Initialize as pointer to struct with zero values as as implied by the doc comment. This initialization matches similar values in the standard library.
This commit is contained in:
parent
0e33ab35f9
commit
7f59b56ea4
|
@ -154,7 +154,7 @@ func hostPortNoPort(u *url.URL) (hostPort, hostNoPort string) {
|
|||
}
|
||||
|
||||
// DefaultDialer is a dialer with all fields set to the default zero values.
|
||||
var DefaultDialer *Dialer
|
||||
var DefaultDialer = &Dialer{}
|
||||
|
||||
// Dial creates a new client connection. Use requestHeader to specify the
|
||||
// origin (Origin), subprotocols (Sec-WebSocket-Protocol) and cookies (Cookie).
|
||||
|
|
|
@ -17,8 +17,6 @@ import (
|
|||
|
||||
var addr = flag.String("addr", "localhost:8081", "http service address")
|
||||
|
||||
var dialer = websocket.Dialer{} // use default options
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
log.SetFlags(0)
|
||||
|
@ -26,7 +24,7 @@ func main() {
|
|||
u := url.URL{Scheme: "ws", Host: *addr, Path: "/"}
|
||||
log.Printf("connecting to %s", u.String())
|
||||
|
||||
c, _, err := dialer.Dial(u.String(), nil)
|
||||
c, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
|
||||
if err != nil {
|
||||
log.Fatal("dial:", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue