Conn.Dial
Overview
Dial connects to the WebSocket url.
Part of the ws package — Node.js analog: ws.
Method on Conn — call it on a value of that type after constructing or receiving one from a constructor.
Signature
go
func Dial(ctx context.Context, url string, header http.Header) (*Conn, error)Compare: Node.js · Standard Go · gox
js
const ws = new WebSocket('wss://example.com');go
// gorilla/websocket Upgrader or Dialergo
import "github.com/sahilkhaire/gox/ws"
conn, err := ws.Dial(ctx, "wss://example.com", nil)Example
go
import "github.com/sahilkhaire/gox/ws"
conn, err := ws.Dial(ctx, "wss://example.com", nil)Tips
Obtain a Conn value first (see constructors on the package overview), then call Dial.
Standard library alternative
gox wraps the Go standard library or a trusted dependency with Node-familiar naming. You can use the underlying library directly — see the package overview for escape hatches.