0PricingLogin
Go Academy · Lesson

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

  1. WebSocket Basics
  2. Using gorilla/websocket
  3. Broadcasting Messages
  4. Connection Management
← Back to Go Academy