Go works well for the production side of recommendation systems: serving low-latency recommendations, collecting events, computing features and refreshing caches. You can implement classic collaborative filtering in plain Go, use a Go-based engine such as Gorse, or serve embeddings and models trained in Python. Heavy model training is still easier in Python, but Go handles the high-throughput online path very well.
This article covers the main recommendation approaches, a runnable collaborative filtering example, the architecture of a Go recommendation service and the practical issues you will hit.
Most systems combine a few well-known techniques.
| Approach | Idea | Strength | Weakness |
|---|---|---|---|
| Content-based | Recommend items similar to those a user liked, using item attributes | Works for new items | Limited discovery |
| Collaborative filtering | Recommend what similar users liked | Finds unexpected items | Cold start for new users and items |
| Matrix factorisation | Learn user and item vectors from interactions | Compact, scalable | Needs training pipeline |
| Hybrid and neural | Combine signals with learned ranking models | Best accuracy | More complex to build and serve |
Production systems usually run in two stages: candidate generation (retrieve a few hundred plausible items quickly) and ranking (score those candidates with a richer model). Go is a natural fit for both stages at serving time.
errgroup, then merge results under a single deadline.go-redis and database drivers cover storage, and Gorse offers a complete open-source recommender engine written in Go.The gap is on the training side: Python has far better tooling (PyTorch, implicit, LightFM and many research implementations).
The example below implements user-based collaborative filtering with cosine similarity. For a target user it finds similar users, then predicts a score for each unseen item as a similarity-weighted average of other users' ratings.
Output:
The map iteration order in Go is random, so the code sorts results and breaks ties by name to keep the output deterministic. Note that "coco" scores 5.00 because only one similar user rated it. A real system dampens scores with few supporters, for example by shrinking toward the item mean, and normalises ratings per user before computing similarity.
This brute-force approach compares the user to everyone, which is O(users) per request. It is fine for thousands of users. At larger scale, precompute item-to-item similarities offline, or use an approximate nearest neighbour index over embeddings.
A typical production layout looks like this:
Return a sensible fallback, such as popular items, whenever personalised results are unavailable. That also covers the cold-start case for new users.
Gorse is an open-source recommender system written in Go. It ingests users, items and feedback through a REST API, trains collaborative filtering and ranking models in the background and serves recommendations. It is a reasonable starting point if you want a ready-made engine instead of building the pipeline yourself. Review its current documentation for supported storage backends and deployment options before adopting it.
For custom models, train embeddings in Python, export them, and either load them into a vector index or call a model server from Go. Gonum is useful for vector math such as dot products and normalisation inside the service.
Go is good for serving and data pipelines. Training complex models is usually done in Python, and the results are served from Go.
Item-to-item collaborative filtering based on co-occurrence or cosine similarity is simple, explainable and effective as a first version.
Fall back to popular or trending items, ask for a few preferences at sign-up, and use session behaviour as soon as it is available.
If you use embeddings and have many items, an approximate nearest neighbour index helps. Go clients exist for the common vector stores, and a small catalogue can be searched in memory.
Go is a strong choice for the online part of a recommendation system: fast, concurrent and easy to operate. Implement simple collaborative filtering directly, consider Gorse for a complete engine, and train advanced models in Python while serving them from Go. Plan for cold start, evaluation and a clear fallback from the beginning.