We may earn an affiliate commission when you visit our partners.
Course image
Trevor Sawler

WebSockets are a technology that allows developers to build highly interactive, extremely fast web applications. Since WebSockets are supported by all modern browsers, and have been for years now, there is no reason why they cannot be implemented on any modern web application. This course will show you how to work with WebSockets with Go.

Read more

WebSockets are a technology that allows developers to build highly interactive, extremely fast web applications. Since WebSockets are supported by all modern browsers, and have been for years now, there is no reason why they cannot be implemented on any modern web application. This course will show you how to work with WebSockets with Go.

We will work with two kinds of WebSocket technologies: first, with simple calls directly from our web application to all connected browsers, where all functionality is handled by our application. The web application we'll build is a simple chat application, which will allow users to chat back and forth, and will show the list of connected users, updated in real time.

Next, we'll take advantage of a Pusher compatible server (or Pusher itself, if you prefer) and use that server as a message broker between our web application and all connected clients.

I am a firm believer that learning how to use a particular technology works best when applying it to a real-world situation. All too often, tutorials and courses over simplify what they are trying to teach, and create an artificial environment where things are so simple that what is being taught looks easy enough, but you immediately run into problems when trying to implement it on a more complex project. So, to implement and learn about WebSockets and Pusher, we'll build a web application which monitors remote servers and hosts, and notifies us in real-time when a service goes down or comes back up again. We will send notifications in real time using WebSockets (which will update the appropriate content on the pages being viewed by all connected clients), by email, and, as a bonus, we'll also learn how to send notifications using text messages (SMS) with  Twilio.

Enroll now

What's inside

Learning objectives

  • How to work with websockets in go (golang)
  • How to build a real-time, responsive application using websockets
  • How to connect to third party services like pusher, and how to use our own self-hosted pusher-compatible service
  • How to build a real-time server monitoring web application
  • How to schedule periodic events in go
  • How to write tests for websocket handlers
  • The basics of building a secure web application in go
  • How to send sms messages with go using twilio

Syllabus

Course overview and setting up our development environment

Who I am, and what we are going to do

About me

How to install Go on Windows and a Mac

Read more

Setting up Visual Studio Code for Go

Learn the basics of websockets using gorilla/mux

An overview of what we'll build in this section

How to build a very simple web application so we can get started

Writing Go code to upgrade a connection from http to ws

The basics of connecting to a websocket endpoint

Listening for different kinds of events

Listening for client actions in our application

Showing connected users in our chat application

Just fixing a minor problem

Another minor fix

Sending messages to all connected users

Some housekeeping issues with our code base

Installing the reconnecting websocket library

Giving visual feedback when a user connects to the chat application

Test your knowledge of using Javascript to work with websockets

Connect a web application to a Pusher compatible server

An overview of the finished project

Installing some necessary software

Getting the starter code

Fixing a typo in the config.yml

Connecting to our Pusher compatible server

Sending an event from our application to the Pusher compatible server

Test your knowledge of connecting to a Pusher compatible server in Javascript

Set up a web application to monitor services on remote hosts

Getting our database ready for use

Setting up models to map our code to our database

Setting up HTML forms for managing hosts

Setting up our code to handle the host form

Passing the necessary data to the host form page

Writing the database method to save a new host to the database

Writing the database methods for getting and updating a host

Updating the host handler to accept updates

Listing all of our hosts in the web application

Getting started with adding services to our host

Improving our host services logic

Adding and removing host services in the database

Improving the way we list host services for the end user

Adding information to our overview page

Showing the status of all services on the overview page

Setting up the overview pages for services of a given status (healthy, pending, problem, and warning)

Some minor changes for the new version of Go

Setting up the service status tabs on the host page

Just a bit of clean up

Writing the code necessary to allow for manual checks of a given service

Finalizing the code necessary to allow for manual checks of a given service

Check your knowledge of sending an AJAX request using Javascript

Learn how to monitor services on remote hosts on a predefined schedule

Establishing a monitoring schedule that will run in the background

Just updating our chi router dependency

Continuing to write the code for the monitoring schedule

Finalizing the code for the monitoring schedule

Learn how to push events to clients over websockets

Pushing websocket events when monitoring starts or stops

Running a local web server so that we have something to test against

How to run checks of external host services

Pushing websocket events to connected clients in real time

Updating the problem, pending, healthy and warning service counts in real time

Just a bit of housekeeping

Updating the host service status tables in real time

An overview of what the exercise entails

How I solved the exercise problem

Displaying the monitor schedule in a table

Changing the content of the schedule page in real time

Pushing websocket events when turning host services on and off

Ensuring that websocket events are pushed after a manual check

Displaying and saving a history of host service status changes

Just some housekeeping and code cleanup

Pushing a websocket event to a single user

Setting up Mailhog on a Mac for testing email services

Setting up Mailhog on Windows for testing email services

Sending email alerts when host service status changes

Overview of sending SMS messages with Twilio

Set up a developer account on Twilio

Optionally sending SMS alerts when a host service status changes

Monitor HTTPS connections and ssl certificates in real time

Getting started with monitoring SSL enabled web servers

Writing the code to monitor SSL enabled web servers

Monitoring SSL certificates on remote servers

Learn how to write tests for handler methods, and for handlers that interact with a remote service

A review of how to write tests for handlers

Writing tests that interact with pusher (or ipe)

Updating our test to remove the calls to an external service by mocking Pusher

Good to know

Know what's good
, what to watch for
, and possible dealbreakers
Provides an introduction and foundation of WebSockets for beginners
Useful for developers who want to add real-time functionality to their web applications
Practical approach with building a real-time server monitoring application
Covers advanced topics like sending SMS messages with Twilio
This course is not recommended if you want to learn about a specific version of a software or tool

Save this course

Save Working with WebSockets in Go (Golang) to your list so you can find it easily later:
Save

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in Working with WebSockets in Go (Golang) with these activities:
Follow a WebSocket tutorial
Improve your understanding of WebSocket fundamentals and implement them in Go by following a tutorial.
Browse courses on WebSockets
Show steps
  • Find a reputable WebSocket tutorial.
  • Follow the tutorial step-by-step, implementing the code in Go.
  • Test your implementation to ensure it works as expected.
Attend a WebSocket workshop
Gain hands-on experience with WebSockets by attending a workshop.
Browse courses on WebSockets
Show steps
  • Find a WebSocket workshop that fits your schedule and interests.
  • Register for the workshop and prepare for the sessions.
  • Attend the workshop and actively participate in the exercises.
  • Follow up with the workshop organizers or instructors for additional support.
Code WebSocket handlers
Develop your proficiency in writing WebSocket handlers by practicing coding them in Go.
Browse courses on WebSockets
Show steps
  • Set up a project with the necessary Go dependencies.
  • Implement a simple WebSocket handler that echoes messages.
  • Implement a WebSocket handler that broadcasts messages to all connected clients.
  • Test your handlers to ensure they work as expected.
Three other activities
Expand to see all activities and additional details
Show all six activities
Test WebSocket handlers
Gain confidence in your WebSocket handlers by thoroughly testing them.
Browse courses on WebSockets
Show steps
  • Set up a testing framework for Go.
  • Write tests for your WebSocket handlers.
  • Run the tests and fix any issues that arise.
Write a blog post about WebSocket
Enhance your understanding of WebSockets by writing a blog post that explains the concepts to others.
Browse courses on WebSockets
Show steps
  • Choose a specific aspect of WebSockets to focus on.
  • Research the topic thoroughly.
  • Write a clear and concise blog post that explains the concepts.
  • Publish your blog post and share it with others.
Contribute to a WebSocket library
Deepen your knowledge of WebSockets and Go by contributing to a WebSocket library.
Browse courses on WebSockets
Show steps
  • Find an open-source WebSocket library that interests you.
  • Identify an area where you can contribute.
  • Submit a pull request with your contribution.
  • Collaborate with other contributors to improve the library.

Career center

Learners who complete Working with WebSockets in Go (Golang) will develop knowledge and skills that may be useful to these careers:
Go Developer
As a Go Developer, you will specialize in developing and maintaining Go-based applications. This course on WebSockets in Go will provide you with the skills to build real-time and interactive applications using Go. You will learn how to establish WebSocket connections, handle client interactions, and send data efficiently, giving you the skills to build scalable and responsive web applications.
Full-Stack Developer
Full Stack Developers are responsible for both the front-end and back-end development of web applications. This course on WebSockets will be beneficial for your career as a Full Stack Developer, as it will provide you with the skills to build real-time features and enhance the user experience of your web applications. You'll learn how to implement WebSockets using Go, allowing for efficient and scalable communication between the client and server.
Web Application Developer
As a Web Application Developer, you'll be responsible for designing, developing, and maintaining web applications. This course on WebSockets in Go will provide you with the skills to build real-time, interactive web applications. You'll learn how to establish WebSocket connections, handle client actions, send data to connected clients, and more, all of which are essential skills for a Web Application Developer.
Back-End Developer
Back-End Developers focus on the server-side development of web applications. This course on WebSockets in Go will be beneficial for your career as a Back-End Developer, as it will provide you with the skills to build real-time functionality into web applications. You'll learn how to set up WebSocket servers, handle incoming requests, and send data to connected clients, giving you the skills to create scalable and interactive web applications.
Software Engineer
Software Engineers design, develop, test, and maintain software systems. This course on WebSockets in Go may be useful for your career as a Software Engineer, as it will provide you with the skills to implement real-time communication features in software applications. You'll learn how to establish WebSocket connections, handle client interactions, and send data efficiently, which are valuable skills for building responsive and interactive software systems.
Node.js Developer
Node.js Developers specialize in developing and maintaining Node.js applications. This course on WebSockets in Go may be useful for your career as a Node.js Developer, as it will provide you with the skills to integrate WebSockets into your Node.js applications. You'll learn how to establish WebSocket connections, handle incoming data, and send data to connected clients, giving you the skills to build real-time and interactive web applications using Node.js.
Python Developer
Python Developers specialize in developing and maintaining Python-based applications. This course on WebSockets in Go may be useful for your career as a Python Developer, as it will provide you with the skills to integrate WebSockets into your Python applications. You'll learn how to establish WebSocket connections, handle incoming data, and send data to connected clients, giving you the skills to build real-time and interactive web applications using Python.
C++ Developer
C++ Developers specialize in developing and maintaining C++-based applications. This course on WebSockets in Go may be useful for your career as a C++ Developer, as it will provide you with the skills to integrate WebSockets into your C++ applications. You'll learn how to establish WebSocket connections, handle incoming data, and send data to connected clients, giving you the skills to build real-time and interactive web applications using C++.
C# Developer
C# Developers specialize in developing and maintaining C#-based applications. This course on WebSockets in Go may be useful for your career as a C# Developer, as it will provide you with the skills to integrate WebSockets into your C# applications. You'll learn how to establish WebSocket connections, handle incoming data, and send data to connected clients, giving you the skills to build real-time and interactive web applications using C#.
PHP Developer
PHP Developers specialize in developing and maintaining PHP-based applications. This course on WebSockets in Go may be useful for your career as a PHP Developer, as it will provide you with the skills to integrate WebSockets into your PHP applications. You'll learn how to establish WebSocket connections, handle incoming data, and send data to connected clients, giving you the skills to build real-time and interactive web applications using PHP.
Ruby Developer
Ruby Developers specialize in developing and maintaining Ruby-based applications. This course on WebSockets in Go may be useful for your career as a Ruby Developer, as it will provide you with the skills to integrate WebSockets into your Ruby applications. You'll learn how to establish WebSocket connections, handle incoming data, and send data to connected clients, giving you the skills to build real-time and interactive web applications using Ruby.
Web Developer
This course may help with a career as a Web Developer, where you can build and maintain websites and web applications. Your knowledge of WebSockets, which enable real-time data transfer between a web server and a web client, will be beneficial in this role. This course teaches you how to work with WebSockets in Go, providing you with a valuable skill for web development.
Front-End Developer
Front-End Developers are responsible for the user interface and functionality of websites and web applications. This course on WebSockets in Go may be useful for your career as a Front-End Developer, as it will provide you with the skills to implement real-time features in web applications. You'll learn how to establish WebSocket connections from the client side, handle incoming data, and update the user interface in real-time, giving you the skills to build dynamic and engaging web applications.
JavaScript Developer
JavaScript Developers specialize in developing and maintaining JavaScript-based applications. This course on WebSockets in Go may be useful for your career as a JavaScript Developer, as it will provide you with the skills to integrate WebSockets into your JavaScript applications. You'll learn how to establish WebSocket connections, handle incoming data, and send data to connected clients, giving you the skills to build real-time and interactive web applications using JavaScript.
Java Developer
Java Developers specialize in developing and maintaining Java-based applications. This course on WebSockets in Go may be useful for your career as a Java Developer, as it will provide you with the skills to integrate WebSockets into your Java applications. You'll learn how to establish WebSocket connections, handle incoming data, and send data to connected clients, giving you the skills to build real-time and interactive web applications using Java.

Reading list

We've selected seven books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in Working with WebSockets in Go (Golang).
Is fit for this supplementary reading list because it provides detailed information about the concepts involved with working with WebSockets in general, though not specifically in Golang.
Provides a practical guide to building real-time web applications with Go. It covers everything from setting up a Go development environment to deploying a real-time web application.
Is fit for this supplementary reading list because it provides a detailed introduction to the Rust programming language. Though Rust is not used in this course, it shares some similarities with Go, so learning Rust can help strengthen your understanding of Go.
Is fit for this supplementary reading list because it provides a detailed introduction to the Go programming language. Though this course assumes some knowledge of Go, this book great way to learn Go from the beginning or brush up on your skills.
Provides a comprehensive guide to web programming with Go. It covers everything from setting up a Go web development environment to deploying a web application.
Is fit for this supplementary reading list because it provides detailed information about web development in Go. Though this course teaches how to build real-time server monitoring applications with Go, this book great way to learn how to build web applications in Go.
Is fit for this supplementary reading list because it provides a very basic introduction to the Go programming language. Though this course assumes some knowledge of Go, this book great way to learn Go for complete beginners.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Here are nine courses similar to Working with WebSockets in Go (Golang).
Getting Started with ASP.NET Core 2 SignalR
Stateful Reactive Concurrent SPAs with SignalR and...
Real-time Web Applications
Introduction to Testing in Go (Golang)
Securing Your Node.js 5 Web App
Building Web Applications with Go - Intermediate Level
Build a Node Server backend with Express
Web Development with ExpressJS
Building an End-to-end SPA Using ASP.NET Core Web API and...
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2024 OpenCourser