Using gorilla/websocket
Upgrade and handle connections.
The gorilla/websocket Library
gorilla/websocket is the most widely used Go WebSocket library. It handles the upgrade handshake and gives you a connection object to read and write frames. Install with go get github.com/gorilla/websocket.
import "github.com/gorilla/websocket"The Upgrader
An Upgrader turns an HTTP request into a WebSocket connection. You configure buffer sizes and an origin check.
var upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
}All lessons in this course
- WebSocket Basics
- Using gorilla/websocket
- Broadcasting Messages
- Connection Management