Skip to content
Node: wsgithub.com/sahilkhaire/gox/ws

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) *Server

Compare: Node.js · Standard Go · gox

js
const wss = new WebSocket.Server({ server });
go
// gorilla/websocket Upgrader or Dialer
go
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.

Back to ws package overview

MIT Licensed · Built for Node.js developers moving to Go