← All projects

Tic-Tac-Go

Multiplayer Tic-Tac-Toe over WebSockets in Go — a lobby API with real-time game state and win detection.

  • Go
  • WebSockets
  • Gin
  • Real-time

· github.com/carloscardoso05/tic-tac-go

Overview

Tic-Tac-Go is a multiplayer Tic-Tac-Toe API built on WebSockets. Two players join a room over a single GET /ws connection and exchange plain-JSON events — the server owns the game state, validates every move, and broadcasts state changes to both clients.

Screenshot placeholder Output of go test -v ./internal/lobby — 12 passing tests covering marker placement, turn rotation, wins (horizontal/vertical/diagonal) and draws. Replace with a terminal capture.

Features

  • Event-driven protocolcreate, join, mark, leave as flat JSON over one WebSocket connection.
  • Lobby + broadcast — a hub dispatches state to all clients in a room.
  • Win detection — horizontal, vertical, both diagonals, and draws.
  • Table-driven tests with testify covering every board scenario.

Tech stack

  • Go 1.26 with Gin
  • coder/websocket (WebSocket library)
  • google/uuid for room/player identity
  • testify for tests

Running locally

cd api
go run ./cmd/server        # ws://localhost:8080/ws
go test ./...

Connect with any WebSocket client (e.g. wscat -c ws://localhost:8080/ws) and send {"type":"create","data":{"room":"..."}}.

Why this project?

Concurrency is the point: shared mutable game state, message ordering, and broadcast semantics. Go’s goroutines and channels make the hub design natural, and the test suite proves the rules engine is correct.