Course Overview
Go, often referred to as Golang, is well-known for making it remarkably easy to work with concurrency. In order to make a particular function run concurrently, all we have to do is prepend the word "go" to the function call, and it cheerfully runs in the background, as a GoRoutine. Go's built in scheduler takes are of making sure that a given GoRoutine runs when it should, and as efficiently as it can.
However, this does not mean that working with concurrency is simple in Go—thread safe programming takes careful planning, and most importantly it requires that developers have an absolutely solid understanding of how Go deals with concurrency.
In the standard library, Go offers us several ways of dealing with concurrently running parts of our program, right in the standard library: sync.WaitGroup, which lets us wait for tasks to finish; sync.Mutex, which allows us to lock and unlock resources, so that no two GoRoutines can access the same memory location at the same time; and finally, Channels, which allow GoRoutines to send and receive data to and from each other.
Go's approach to concurrency is fairly straightforward, and is more or less summed up this mantra: Don't communicate by sharing memory; instead, share memory by communicating. Channels are the means by which we usually share memory by communicating.
In this course, we'll cover the use of WaitGroups, Mutexes, and Channels, and we'll do so in detail. We'll also cover some of the problems inherent in concurrency, including early program termination and race conditions. Initially, we'll gain a good understanding of how these things work by solving some of the classic problems found in the field of computer science, including the Dining Philosophers, the Producer/Consumer problem, and the Sleeping Barber. These problems are classics for a reason: they force a developer to figure out the best approach to working with code that run concurrently, or in parallel.
Finally, we'll finish the course out with a more "real-world" problem, where we have to register a customer for some kind of subscription service, and take care of invoicing, registration, and all the things necessary to get a new customer up and running. We'll do so, naturally, as quickly as we can by dividing the necessary tasks up into smaller tasks, and having them run concurrently.
Please note that this course requires you to download Docker Desktop from Docker. If you are a Udemy Business user, please check with your employer before downloading software.
FAQ
FAQ area empty
Course curriculum
Chương 1 Introduction 7 bài · 16 phút
Chương 2 Goroutines, the go keyword, and WaitGroups 6 bài · 31 phút
- What we'll cover in this section Học thử 1:03
-
Creating GoRoutines and identifying a problem 6:33
-
WaitGroups to the rescue 8:39
-
Writing tests with WaitGroups 6:54
-
Challenge: working with WaitGroup 2:25
-
Solution to Challenge 5:00
Chương 3 Race Conditions, Mutexes, and an Introduction to Channels 12 bài · 1 giờ 21 phút
-
What we'll cover in this section 4:21
-
Race Conditions: an example 5:10
-
Adding sync.Mutex to our code 3:25
-
Testing for race conditions 3:39
-
A more complex example 13:14
-
Writing a test for our weekly income project 3:33
-
Producer/Consumer - Using Channels for the first time 7:36
-
Getting started with the Producer - the pizzeria function 9:57
-
Making a pizza: the makePizza function 10:47
-
Finishing up the Producer code 7:29
-
Creating and running the consumer: ordering a pizza 7:21
-
Finishing up our Producer/Consumer project 4:39
Chương 4 A Classic Problem: The Dining Philosophers 6 bài · 43 phút
-
What we'll cover in this section 1:54
-
Getting started with the problem 17:53
-
Implementing the diningProblem logic 12:45
-
Challenge: Printing out the order in which the meal is finished 1:20
-
Solution to challenge 2:43
-
Writing a test for our program 6:35
Chương 5 Channels, and another classic: The Sleeping Barber problem 10 bài · 1 giờ 22 phút
-
What we'll cover in this section 4:05
-
Introduction to channels 13:48
-
The select statement 12:11
-
Buffered Channels 6:17
-
Getting started with the Sleeping Barber project 5:33
-
Defining some variables, the barber shop, and getting started with the code 8:22
-
Adding a Barber 13:25
-
Starting the barbershop as a GoRoutine 6:23
-
Sending clients to the shop 7:53
-
Trying things out 4:11
Chương 6 Final Project - Building a Subscription Service 15 bài · 1 giờ 39 phút
-
What we'll cover in this section 1:19
-
Setting up a simple web application 8:01
-
Setting up our Docker development environment 5:20
-
Adding postgres 8:11
-
Setting up a Makefile 4:19
-
Adding sessions & Redis 4:39
-
Setting up the application config 4:39
-
Setting up a route & handler for the home page, and starting the web server 6:26
-
Setting up templates and building a render function 18:32
-
Adding session middleware 2:07
-
Setting up additional stub handlers and routes 5:02
-
Implementing graceful shutdown 6:37
-
Populating the database 2:38
-
Adding a data package and database models 7:02
-
Implementing the login/logout functions 13:52
Chương 7 Sending Email Concurrently 8 bài · 47 phút
-
What we'll cover in this section 1:40
-
Getting started with the mailer code 18:27
-
Building HTML and Plain Text messages 7:10
-
Sending a message (synchronously) 4:27
-
Getting started sending a message (asynchronously) 7:45
-
Writing a helper function to send email easily 1:52
-
Sending an email on incorrect login 2:55
-
Adding cleanup tasks to the shutdown() function 3:01
Chương 8 Registering a User and Displaying Plans 8 bài · 47 phút
-
What we'll cover in this section 1:00
-
Adding mail templates and URL signer code 5:20
-
Starting on the handler to create a user 9:07
-
Activating a user 6:00
-
Giving user data to our templates 2:41
-
Displaying the Subscription Plans page 12:37
-
Adding a route and trying things out for the "Plans" page 6:44
-
Writing a stub handler for choosing a plan 3:22
Chương 9 Adding Concurrency to Choosing a Plan 5 bài · 52 phút
-
What we'll cover in this section 1:01
-
Getting the plan id, the plan, and the user 7:40
-
Generating an Invoice 9:40
-
Generating a manual 21:10
-
Trying things out, subscribing a user, updating the session, and redirecting 12:12
Chương 10 Testing 9 bài · 1 giờ 27 phút
-
What we'll cover in this section 0:52
-
Setting up our tests 8:27
-
Testing Routes 8:00
-
Testing the Renderer 11:40
-
Modifying the data package to make it testable 14:08
-
Implementing the PlanTest type 4:26
-
Getting started testing Handlers 14:35
-
Testing the Login Handler 13:53
-
Testing a handler that uses concurrency 11:06
Requirment
-
A good understanding of the Go programming language
-
A Windows, Macintosh, or Linux computer with a connection to the Internet
Outcomes
-
Learn about the various ways Go makes working with concurrent programing simple
-
Understand how concurrency works, and its advantages and pitfalls
-
Learn how WaitGroups, Mutexes, and channels work
-
Master concurrency by working with classic computer science problems, and by building a real-world example
0 Student
9 Courses
0 review