go-websocket

A GPL-licensed WebSocket server written in Go

Introduction

go-websocket is a GPL-licensed WebSocket server implementation written in Go. The library provides a simple HTTP handler that facilitates WebSocket connections, making it easy to add real-time bidirectional communication to Go applications.

The project is available on GitHub and is released under the GPL-3.0 license.

Features

Installation

To install go-websocket, use:

go get seehuhn.de/go/websocket

Usage

The library uses a websocket.Handler object to manage connections. Developers define a callback function that processes each client connection, handling message reception and transmission through reader/writer interfaces.

Example of a simple echo server:

import "seehuhn.de/go/websocket"

handler := websocket.Handler(func(conn *websocket.Conn) {
    // Handle incoming messages and send responses
    // Messages received from clients are reflected back
})

Documentation

Full API documentation is available on godoc.org or through the command line:

go doc seehuhn.de/go/websocket

The source code is available on github.com/seehuhn/go-websocket.

Source Code

View on GitHub: seehuhn/go-websocket