A feature-rich chat room application written in Go. It provides real-time messaging, file transfer, end-to-end encryption, emoji support, user sessions, and a desktop GUI built with the Fyne framework.
Project Structure
chatroom/
├── cmd/ # Application entrypoints (server & client)
├── internal/ # Private application code (client, server, networking)
├── pkg/ # Public libraries/helpers
├── assets/ # Static resources (images, icons)
└── uploads/ downloads/ # File transfer storage
Application Construction
- Server: implemented under
cmd/serverandinternal/server, accepts client connections, routes messages, manages users and file transfers. - Client: implemented under
cmd/clientandinternal/client, provides the GUI, handles user input, encryption, and file transfer logic. - Shared: protocol definitions and utilities are in
internal/shared(message formats, encryption helpers, models). - GUI: Desktop GUI uses the
fynetoolkit (seeinternal/client/gui).
Setup & Run Instructions
-
Prerequisites:
- Go:
1.21or newer installed and on yourPATH. - Git: to clone the repository (optional if you already have the workspace).
- Go:
-
Install Go module dependencies (from project root):
go mod download- Run server (development):
go run cmd/server/main.go- Run client (development):
go run cmd/client/main.goList of Necessary Dependencies
-
Go toolchain:
go(version1.21recommended). -
Primary modules (declared in
go.mod):fyne.io/fyne/v2(GUI toolkit)- Other modules are used indirectly by Fyne and for utilities; run
go mod tidyandgo mod downloadto fetch them.
-
Optional / environment:
- A desktop environment for the GUI client (X11 / Wayland on Linux).
- Network connectivity between client and server hosts.
Quick Troubleshooting
- If you see missing module errors: run
go mod tidythengo mod download. - If the GUI doesn't start on Linux, ensure you have a graphical session and display drivers installed; run the client from a desktop session (not a headless SSH session) or use X11 forwarding if necessary.
Server flags & configuration
-
The server binary accepts two optional flags (set when starting the server):
-n: Generate a NEW room key and delete any existing save state files (room.key,server_state.json).-o: Use an existing room key if available (default behavior when present).
-
Example: start a fresh server with a new room key:
go run cmd/server/main.go -n- The server listens by default on TCP port
9000. This is configured incmd/server/main.gowhereserver.New(":9000")is used; if you need to change the port, edit that file or build a small wrapper.
State & Storage Files
room.key— symmetric room key used for message encryption; generated by the server and stored in the server working directory.server_state.json— serialized server state (connected users, file transfers, etc.).uploads/anddownloads/— local folders used by the server/client for storing transferred files (in the repository root).
Client connection behavior
- The GUI client will attempt to connect to
:9000(localhost port 9000) by default. The connection address is hard-coded in the GUI atinternal/client/gui/gui.goin the login dialog (a.client.Connect(":9000")). - To connect to a remote server, either run the client on the same host (with port forwarded), or change the
address in
internal/client/gui/gui.go(or extend the client to accept a CLI flag or environment variable).
Usage examples
- Start server (reuse existing key/state if present):
go run cmd/server/main.go- Start server (create fresh room key & state):
go run cmd/server/main.go -n- Start client GUI (connects to
localhost:9000):
go run cmd/client/main.go
