Server.NewServer
Overview
NewServer creates a WebSocket server with the given upgrader (nil uses DefaultUpgrader).
Part of the ws package — Node.js analog: ws.
Method on Server — call it on a value of that type after constructing or receiving one from a constructor.
Signature
go
func NewServer(up *Upgrader) *ServerCompare: Node.js · Standard Go · gox
js
const wss = new WebSocket.Server({ server });go
// gorilla/websocket Upgrader or Dialergo
import "github.com/sahilkhaire/gox/ws"
srv := ws.NewServer()Example
go
import "github.com/sahilkhaire/gox/ws"
srv := ws.NewServer()Tips
Obtain a Server value first (see constructors on the package overview), then call NewServer.
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.