Member-only story

How to Build a Concurrent Chat App With Golang and WebSockets

Build a real-time chat app with Go

Michael Bogan
Better Programming

person looking at a smartphone they’re holding in their hands
Photo by Yura Fresh on Unsplash

Go emerged from Google out of a need to build highly performant applications using an easy-to-understand syntax. It’s a statically typed, compiled language developed by some of the innovators of C, without the programming burden of manual memory management. Primarily, it was designed to take advantage of modern multicore CPUs and networked machines.

In this article, I’ll demonstrate the capabilities of Go. We’ll take advantage of Go’s ability to easily create concurrent apps to build a chat app. On the back end, we’ll use Redis as the intermediary to accept messages from the browser and send them to the subscribed clients. On the front end, we’ll use WebSockets via socket.io to facilitate client-side communication. We’ll deploy it all on Heroku, a PaaS provider that makes it easy to deploy and host your apps. Just as Go makes programming such an application simple, Heroku makes it easy to supplement it with additional infrastructure.

Channels in Go

What developers find appealing about Go is its ability to communicate concurrently, which it does through a system called channels. It’s important to draw upon an oft-cited distinction between concurrency and parallelism. Parallelism is the process by…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Responses (2)

What are your thoughts?

Hi Michael! Thanks for the post. I've tried to replicate the code and I'm currently on deployment, but I'm not sure it's working well since I'm only getting the "username" and "chat text" boxes on the heroku link. Since it is a chat app, I should be…

1

Learn to create a real-time chat application using Golang programming language and WebSockets, enabling concurrent communication and seamless messaging between multiple users.