Contents
    Lex Melnykow Head of Web

    Building a Chat App with Go in 2022: Tips, Features, and Examples

    For business purposes or just to stay in touch with friends and family, messaging apps and chat platforms are one of the main ways of communication these days. Many of them offer more than plain text messages, including media sharing, video calls, groups, and channels. There are several chat apps that are known and used globally and many locally-based or industry-specific platforms. Although the competition is strong, there are still niches in which your chat app concept can succeed and grow in popularity due to its unique offerings.

    Along with choosing the right target audience and functionality, the key aspects that determine a chat app’s success are its code quality and the technologies used. A slow, glitchy, or potentially unsafe app has low chances of acquiring a large user base and becoming popular. So, if you wonder how to build a chat app and what technologies to use, you’ve come to the right place. We at Surf have been providing development services for over 12 years, working with clients from banking, digital media, retail, and other industries. In the article, we’ll talk about the main features of a modern chat application, what challenges are likely to arise when creating such a platform and how they can be overcome by using a relevantly new but increasingly popular Go programming language. 

    What is Go

    Developed and publicly released by Google employees in 2009, Go (also called Golang) is a statically typed programming language that uses the advantages of modern multicore processors to offer high performance combined with easy-to-comprehend syntax. Golang has many similarities with Python and C++ and is currently among the TOP-10 most commonly learned languages as many developers of these two languages switch to Go.

    Desktop and mobile apps of Slack, which uses Go in the backend

    Mainly used for backend, web and server-side development, Go offers advanced concurrency capabilities that decrease hardware load and processing time. This, along with fast compiling, extensive support of third-party editors and IDEs, and ease of learning (developers with prior knowledge of other languages can start working with Go within a month) has made it a language of choice for many development companies and renowned brands, including Slack, PayPal, Netflix, Uber, and others. For more on this, check our general overview of what is Golang.

    Now let’s talk about the features of a chat app and how Go can help implement them.

    Hiring Go developers? Make sure to include these questions in candidates’ interviews

    Read more

    Chat app features

    Today, messaging platforms come with many features so that users can share files, make video calls and participate in group conversations. While the final set of features is determined by the app’s concept and business goals, below we’ll discuss those that can be considered more or less essential for any of them, including web chat apps.

    Sign up & login

    The registration process should be as easy for new users as possible. Along with authorization via email and phone number, consider adding quick sign-on options via Gmail and Facebook accounts, Apple ID, and others. Such options not only make the onboarding process smoother but also lets you extract users’ demographic details that can be useful in analytics and business development. Also, don’t forget to integrate an option to protect chats with a password, Touch and Face ID to ensure users’ privacy.

    Contacts synchronization

    To help people connect with their friends and colleagues, a chat app must be able to automatically import their contacts. This is done via a contact synchronization API that scans the phone’s list of contacts, compares them with the app’s database, and stores the matching contacts on the server.

    Messaging

    The core feature of a chat app is the real-time messaging screen where users communicate with each other. In Golang, this is done by using WebSocket package that passes messages from the client app to the server and displays live data to users. Redis, an in-memory database, is used in the backend to store chat history so that a user can access previous messages even when logging in from another device. To protect users’ privacy all data exchange between client apps and the server must be done via HTTPS using SSL cryptography.

    File sharing

    Another main feature of a chat app is an option that allows users to share documents and various media, as well as take photos or record audio directly in the app and instantly send them. This is implemented by using REST and SOAP APIs: while the former is more suitable for web services and has fewer requirements in terms of security, client browser compatibility, and scalability, the latter is more complex and provides enterprise-level security along with ACID (Atomicity, Consistency, Isolation, Durability) compliance.

    Voice & video calls

    The surge in remote working popularity makes a video conferencing feature a must-have of a chat app that can drive up user engagement and create diverse use-case scenarios. Audio and video streaming functionalities are implemented by using WebRTC implementation for Go (such as Pion) — a communication protocol for web transmission of real-time audio, video, and data via peer-to-peer connection. 

    Groups & channels

    To make users be able to form communities and interact with several other users at once, consider adding group functionality. Also, as some messaging apps become extensions of social media platforms or even substitute them, channels can be a good way to attract creators and businesses to your platform. 

    In contrast to groups, where all members interact equally with each other, a channel provides a sort of a public page for its owner, where they can share their content with subscribers and determine how they can interact with it (for example, some channels allow subscribers to communicate in a post’s comment section, while others are ‘read-only’). If you’re going to make channels a major feature of your app, don’t forget to offer  channel creators the analytics tools that can provide insights into their audience and user engagement. 

    Location services

    A chat app can also benefit from using geolocation services, which help users share their live locations and form location-based communities. The feature is implemented by using android.location package for Android app and CLLocationManager Class for iOS app.

    Looking for Go development services? Surf creates Go backend solutions that allow integrating up to 1000 microservices

    Get in touch

    Chat app challenges

    Developing a modern and performant chat app with wide functionality can be full of challenges that have to be tackled at every stage of the development process. Let’s take a look at the most common of them and how using Go helps overcome them.

    App performance

    High performance is a must-have for a chat app: big downtime and slow processing of messages can completely destroy the concept of instant communication, forcing users to seek alternate apps and solutions.

    With performance on par with Java and C++, Go is tens of times faster than Python. Golang uses concurrent threads called goroutines that communicate between themselves via channels. Goroutines are very cheap to create, taking up only a few kBs of memory, meaning there can be thousands of concurrent processes running without impacting the web app’s performance. Compared to Java and Python, goroutines require minimum boilerplate code, making the code more understandable and easier to read. Also, Go boasts efficient garbage collection and, being built into binary, an ability to interact directly with hardware sans any extra layer.

    Among startups that chose Go for application development, is in-built messaging and activity feeds provider Stream. The company’s solutions are used by global companies with over 500 million end-users. Fast compiling, exceptional performance, and strong concurrency support are just some of the reasons the company decided to switch to Go from Python a few years ago. Another company that uses Go for the majority of its backend infrastructure is edtech and communication platform Clever. Today the service has over 20 million active users, providing digital tools for 95,000 U.S. K–12 schools.

    Zumper in-app messaging powered by Stream (Source: https://getstream.io/blog/zumper-stream-case-study/)

    Personalization

    To make your chat app stand out amongst competitors, think about how to tailor your product to users’ needs and provide a unique experience. Satisfied customers are more likely to become loyal adopters of the app and invite friends and relatives, growing your user base. For example, a messaging platform can recommend groups and channels relevant to a customer’s interests, while a web chat app can allow wider customization of notifications and interface.

    Understanding user needs is impossible without detailed analytics of the app’s usage. In the majority of our projects, we at Surf include tools that help figure out the best ways to interact with the users. For example, when developing an e-shop app for beauty stores we’ve integrated it with a marketing platform that analyzes the target audience and creates personal suggestions for shoppers, while in our app concept for KFC we provided for  a system of cross-selling recommendations that suggests meals to users they might like and keep track of their preferences. For example, if a customer regularly removes onion from the list of ingredients, the app would remove it from all meals by default.

    App scalability

    Accommodating a quickly growing user base without speed and stability degradation is crucial for a startup during its active growth phase. The lightweight concurrency approach, code compilation into executable binaries without runtime interpretation, and efficient utilization of all CPU cores make Go an ideal choice for platforms that face scalability challenges.

    As its user base grew, Slack, a global corporate chat app, began facing CPU and memory limitations and even production outages, forcing the company to rework its job queue system. Currently, Slack’s web app uses JQRelay stateless service written in Go. During its busiest days, the platform processes over 1.4 billion jobs at a peak rate of 33,000 per second.

    Development speed

    For startups, more time means more consumed resources and since resources are scarce at the early stage, a dragging development process hurts the whole business. Even after successful launch of initial MVP, it is important to keep up the pace during the phase of active growth. What Golang developers like about the language is the absence of unnecessary complexity — it is easier to read than Python and Java. Also, Go requires fewer dependencies and has a good level of forward compatibility, meaning the Go’s code is likely to run smoothly in the newer versions of software. 

    Godoc, a built-in documentation tool provides more than basic comments — by scanning the source code for any comments and compiling them, it forms the package’s documentation in the form of a plain text or HTML, so the developers can switch between the code and relevant comments in just one click. All of this provides developers with more flexibility and a faster development process.

    While using Go for web development and back-end solutions is a common practice, the front-end of a mobile app can be built using a cross-platform technology, such as Flutter. Compared to native development, where you need to have both iOS and Android developers on board to create two separate apps, Flutter allows one codebase to create apps for both platforms. Not only does this save money, but also speeds up the whole process, meaning faster time to market. For example, when Surf developed mobile apps for a large pharmacy chain, we were able to save about 40% of the initial budget by using Flutter and sharing code across six apps the client requested us to make (iOS and Android apps for each of three brands).

    Online Shop for а Pharmacy Chain by Surf

    Summing things up

    Whether developing a built-in chat messaging app or standalone web solution, choosing Go provides many benefits, including a streamlined development process, fast compiling, great performance, and concurrency support. These days Golang has become an increasingly popular choice for backend, web, and microservices development. While still being a relatively young technology, it sees wide adoption by engineers and development companies, meaning that Go’s support of third-party instruments and SDKs is only likely to widen in the future. 

    Start your project with Surf

    Discuss it