Repolode
LockGit

LockGit/gochat

A lightweight instant messaging backend written in pure Go, supporting private and room broadcast messages over WebSocket and TCP.

Stars
2,937
Forks
475
Open issues
30
Last commit
2 months ago

What is it?

gochat is an instant messaging system implemented in pure Go. It supports one-to-one private messages and broadcast messages within chat rooms, with the layers communicating over RPC so each can be scaled horizontally.

Clients can connect over WebSocket or TCP, and messages are exchanged between the two connection types. Services discover each other through etcd, Redis serves as the message queue and storage layer, and sqlite3 with GORM is used for user data in the demo setup, which can be swapped for another relational database or a heavier queue such as Kafka or RabbitMQ.

The project is split into api, connect, logic, task and site modules, each started separately with a single binary. A Docker setup and run script bring up the dependencies and a demo chat room, and a separate TypeScript and React front end is available.

Key features

  • 01Private messages and room broadcast messaging
  • 02WebSocket and TCP client connections with cross-protocol delivery
  • 03Service discovery via etcd and RPC between layers
  • 04Redis-backed message queue that can be replaced with Kafka or RabbitMQ
  • 05Docker one-command setup for dependencies and demo

Use cases

  • Learning how a horizontally scalable chat server is structured in Go
  • Prototyping an internal chat or messaging feature
  • Building a custom IM backend on top of existing business logic

Quick start

  1. 1

    Clone the repository

    git clone git@github.com:LockGit/gochat.git
  2. 2

    Start the demo with Docker using the bundled script (local address)

    cd gochat && sh run.sh dev 127.0.0.1
  3. 3

    Open http://127.0.0.1:8080 in a browser to enter the chat room

Things to know

  • Requires etcd and Redis, plus a manual multi-module startup, when not using Docker.
  • Messages are not stored in a database; they are only relayed through the queue.
  • The README notes the sample demo does not enable the TCP channel.

In collections

Topics

FAQ

What is gochat?
A lightweight instant messaging backend written in pure Go, supporting private and room broadcast messages over WebSocket and TCP. gochat is an instant messaging system implemented in pure Go. It supports one-to-one private messages and broadcast messages within chat rooms, with the layers communicating over RPC so each can be scaled horizontally.
Is gochat free to use? What license does it have?
gochat is open source under the MIT license. Check the license terms before using it in commercial products.
Is gochat still maintained?
Updated within 6 months. The last commit to gochat was on Sep 1, 2026.
What can I use gochat for?
Learning how a horizontally scalable chat server is structured in Go Prototyping an internal chat or messaging feature Building a custom IM backend on top of existing business logic
How do I install gochat?
Clone the repository: git clone git@github.com:LockGit/gochat.git Start the demo with Docker using the bundled script (local address): cd gochat && sh run.sh dev 127.0.0.1 Open http://127.0.0.1:8080 in a browser to enter the chat room
Where can I get gochat?
The source code and installation instructions are on GitHub: https://github.com/LockGit/gochat

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects