Web Development w/ Google’s Go (golang) Programming Language
4.6 (4,963 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
36,079 students enrolled

Web Development w/ Google’s Go (golang) Programming Language

Learn Web Programming from a University Professor in Computer Science with over 15 years of teaching experience.
4.6 (4,963 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
36,079 students enrolled
Created by Todd Enso McLeod
Last updated 6/2017
English [Auto], Indonesian [Auto], 6 more
  • Italian [Auto]
  • Polish [Auto]
  • Portuguese [Auto]
  • Romanian [Auto]
  • Spanish [Auto]
  • Thai [Auto]
Current price: $44.99 Original price: $64.99 Discount: 31% off
5 hours left at this price!
30-Day Money-Back Guarantee
This course includes
  • 19 hours on-demand video
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to 4,000+ top Udemy courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • Construct server-side applications using today's best practices
  • Acquire an outstanding foundation in the fundamentals of web programming
  • Learn from a University Professor in Computer Science with over 15 years of experience teaching individuals of all ability levels
  • Achieve mastery in the understanding and application of web development
  • Understand servers, routing, restful applications, JSON, AJAX, templates, file servers, cookies, state, UUIDs, HTTP methods, HTTP response codes, sessions, Amazon Web Services, MySQL, MongoDB, load balancers, HTTPS & TLS, Docker, Containers, Virtual Machines, Google Cloud, and App Engine
  • Create web applications using only the Go programming language's standard library
  • Create web applications without using third-party frameworks
  • Build performant distributed applications that dynamically scale
  • Apply cutting-edge web development practices
Course content
Expand all 171 lectures 19:13:16
+ Getting started
5 lectures 38:28
  • server-side?

    • #1 Go

    • #3 Node.js

    • #3 Python

    • #4 Ruby

    • #5 PHP

  • 2006 first intel dual-core processor

  • 2007 Google begins development of Go

    • Rob Pike, Ken Thompson, Robert Griesemer

    • FAQ - Why are you creating a new language?

    • language features

      • take advantage of multiple cores

      • easy concurrency based upon Tony Hoare’s CSP

      • compiled, static type, GC

    • goals

      • efficient compilation

      • efficient execution

      • ease of programming

        • clean syntax

        • distributed teams

  • Why go for web dev?

    • Go was built to do what google does

    • Google is rewriting Google with Go

  • 2009 open-sourced

  • 2012 version 1
Preview 07:39
  • Here are the resources which I think are the best:

  • These notes:

    • https://goo.gl/K5GccY

  • Go programming resources

  • The Code Used In This Course

    • https://github.com/GoesToEleven/golang-web-dev

  • Go Language Fundamentals

    • course

      • https://www.udemy.com/learn-how-to-code/

    • repo

      • https://github.com/GoesToEleven/GolangTraining

  • HTML & CSS

    • course

      • How to Create A Website: An HTML Tutorial and CSS Tutorial

    • repo

      • https://github.com/GoesToEleven/html-css-bootcamp



Course resources
  • variables

    • short variable declaration operator

    • using the var keyword to declare a variable

    • scope

  • data structures

    • slice

    • map

    • struct

      • composite literal

  • functions

    • func (receiver) identifier(parameters) (returns) { <code> }

    • methods

  • composition

  • hands-on exercises #1

  • hands-on exercises #2

use https://play.golang.org/ , screenshot your solution, tweet @Todd_McLeod #golangsnippet

Preview 18:30
  • Bill Gates & Warren Buffet

    • the one word they both chose as the most important contributor to their success: focus

  • Priorities, commitment, focus

    • What is important to you in your life? Prioritize.

    • Can you give time everyday to that which is important? Commitment.

    • Give time to the important everyday. Focus.

  • Drop by drop, the bucket gets filled
How to succeed
+ Templates
14 lectures 01:42:00

Templates allow us to customize information for a use. This is how we get personalized webpages. Templates are the first thing you must learn to do web programming.

Understanding templates

Go encourages the developer to think like a programmer. How can you solve this problem with programming? Could we create a webpage, and merge data with it, by just working with strings?

Templating with concatenation

We are going to store our templates in their own files. It is customary practice to give these files a “.gohtml” extension. We will go through two steps to use our templates: (1) Parse (2) Execute. In this course, we will use ParseGlob and ExecuteTemplate. Package text/template is explained.

  • steps

    • PARSE the template

    • EXECUTE the template

  • performance

    • always parse your templates upon application initialization

    • do not parse your templates every time a user asks for a template

  • *Template

    • container that holds the parsed templates

  • Quick Note

    • Atom will require tweaking of keymap.cson to allow some plugins like Emmet to work on tab expansion

      • 'atom-text-editor[data-grammar="text html gohtml"]:not([mini])':

'tab': 'emmet:expand-abbreviation-with-tab

  • Will allow Emmet plugin to tab expand on files with the gohtml extension

Understanding package text/template: parsing & executing templates

When we execute our template, we can pass data into our template.

Passing data into templates

We can assign values to variables in templates.


{‌{$wisdom := .}}



Variables in templates

This lecture provides you with examples of passing various data types to templates.

Passing composite data structures into templates

During execution functions are found in two function maps: first in the template, then in the global function map. By default, no functions are defined in the template but the Funcs method can be used to add them. Predefined global functions are defined in text/template.

Functions in templates

Pipelines allow us to take the value which is output from one process or function, and pass it as the input to the next function. Also covered in this video: working with package time and formatting type Time in a template.

Pipelines in templates

During execution functions are found in two function maps: first in the template, then in the global function map. By default, no functions are defined in the template but the Funcs method can be used to add them. Predefined global functions are defined in text/template.

Predefined global functions in templates

When parsing a template, another template may be defined and associated with the template being parsed. Template definitions must appear at the top level of the template, much like global variables in a Go program. The syntax of such definitions is to surround each template declaration with a "define" and "end" action. Comments in templates are also covered.

Nesting templates - modularizing your code

In this lecture, we will pass data structures into templates. We will build our data structures using composition. FYI, from wikipedia though modified: Composition is the principle that types should achieve polymorphic behavior and code reuse by their composition (by embedding other types). An implementation of composition typically begins with the creation of various interfaces representing the behaviors that the system must exhibit. The use of interfaces allows this technique to support the Polymorphic behavior that is so valuable. Types implementing the identified interfaces are built and added as needed. Thus, system behaviors are realized without inheritance.

Passing data into templates & composition

In this lecture, we will pass data structures into templates. We will build our data structures using composition. FYI, from wikipedia though modified: Composition is the principle that types should achieve polymorphic behavior and code reuse by their composition (by embedding other types). An implementation of composition typically begins with the creation of various interfaces representing the behaviors that the system must exhibit. The use of interfaces allows this technique to support the Polymorphic behavior that is so valuable. Types implementing the identified interfaces are built and added as needed. Thus, system behaviors are realized without inheritance.

Using methods in templates

Here are several hands-on exercises, with solutions, to help you learn how to pass data to templates.

Hands-on exercises

Package html/template has all of the functionality of package text/template, plus additional functionality specific to HTML pages. In particular, package html/template has context aware escaping so that dangers like cross-site scripting are avoided.

Using package html/template, character escaping, & cross-site scripting
+ Creating your own server
9 lectures 01:01:28

Before we get started building our own server, there are several important things to know:

  • synonymous terms in web programming

    • router

    • request router

    • multiplexer

    • mux

    • servemux

    • server

    • http router

    • http request router

    • http multiplexer

    • http mux

    • http servemux

    • http server

  • client / server architecture

    • request / response pattern

      • like in restaurants

  • OSI model

  • HTTP runs on top of TCP

  • HTTP is a protocol - rules of communication

    • HyperText Transfer Protocol

  • IETF sets recommendations for HTTP

    • Request For Comment - RFC 7230 is for HTTP1.1
Understanding servers

We can create our own tcp server using the net package from the standard library. There are three main steps: (1) Listen (2) Accept (3) Write or Read to the connection. We will use telnet to call into the TCP server we created. Telnet provides bidirectional interactive text-oriented communication using a virtual terminal connection over the Transmission Control Protocol (TCP).

TCP server - write to connection

We will now modify our TCP server to handle multiple connections. We will do this by using goroutines. We will also modify our TCP server to read from the connection. We will then contact our TCP server on port 8080 using our web browser. This will allow us to see the text sent from the browser to the TCP server and how this text adheres to HTTP (RFC 7230).

TCP server - read from connection using bufio.Scanner

Now we are going to read and write from/to our connection.

TCP server - read from & write to connection

We can use the net package to create a client which dials into our TCP server.

TCP server - code a client

Here are two sample TCP server apps.

TCP server - rot13 & in-memory database

Here is how we build the foundation of a TCP server to handle HTTP requests and responses. This video also introduces a hands-on exercise.

TCP server - HTTP request / response foundation hands-on exercise

This is the solution to the hands-on exercise of retrieving the URI and displaying it. The next hands-on exercise is also introduced.

TCP server - HTTP method & URI retrieval hands-on exercise

This is the solution to the hands-on exercise of creating a TCP server that handles requests & responses adhering to HTTP. The server will respond with different code according the both the method and the URI.

TCP server - HTTP multiplexer
+ Understanding net/http package
7 lectures 01:01:13

The best entry point to understanding the net/http package is covered. It is essential to know the standards of HTTP. The first thing you should know about the net/http package is the Handler interface. ListenAndServe takes a value which implements the handler interface.

net/http package - an overview

ListenAndServe is built using what we have just learned: from the net package, Listen & Accept. ListenAndServe takes an address, the port on which you want to listen, and a Handler. It is imperative that you solidly know type Handler.

Understanding & using ListenAndServe

The foundation of the net/http package is type Handler and ListenAndServe. ListenAndServe takes a value of type Handler. Type Handler has two parameters of type ResponseWriter and a pointer to a Request. Understanding the relationship of these parts is essential to building web apps with Go.

Foundation of net/http: Handler, ListenAndServe, Request, ResponseWriter

When a user submits data to a server, that data is attached to the request. Remember, the HTTP specification (RFC 7230) says that a request will have three parts: (1) request line, (2) headers, (3) body (also known as payload). We can retrieve values submitted by the user by working with the Request type. The type Handler has a pointer to a Request (*http.Request) as one of the parameters required by the ServeHTTP method. The Request type is a struct with Form & PostForm fields that allow us to access data submitted by a user. We can also use methods attached to the Request type to access data: FormValue & FormFile.

Retrieving form values - exploring *http.Request

There are other request values which we can retrieve such as the method and the URL.

Retrieving other request values - exploring *http.Request

This video will continue to reinforce your understanding of the net/http package. We will learn how to read documentation and write headers to our response.

Exploring http.ResponseWriter - writing headers to the response

Reviewing: type Handler, ListenAndServe, *Request, ResponseWriter.

+ Understanding routing
6 lectures 58:44

ServeMux is an HTTP request multiplexer. A ServeMux matches the URL of each incoming request against a list of registered patterns and calls the handler for the pattern that most closely matches the URL.

  • ServeMux

    • NewServeMux

      • We can create a *ServeMux by using NewServeMux.

    • default ServeMux

      • We can use the default ServeMux by passing nil to ListenAndServe.

  • Handle

    • takes a value of type Handler

  • HandleFunc

takes a func with this signature: func(ResponseWriter, *Request)

Understanding ServeMux

The differences between func(ResponseWriter, *Request) and HandlerFunc are explained and illustrated.

Disambiguation: func(ResponseWriter, *Request) vs. HandlerFunc

Julien Schmidt’s package httprouter "github.com/julienschmidt/httprouter" is a trie based high performance HTTP request router.

Third-party servemux - julien schmidt’s router

These hands-on exercises will reinforce what you are learning.

Hands-on exercises

Solutions to hands on exercises in folder 022_hands-on/01

Hands-on exercises - solutions #1

Solutions to hands on exercises in folder 022_hands-on/02

Hands-on exercises - solutions #2
+ Serving files
9 lectures 38:31

io.Copy allows us to copy from a reader to a writer. We can use io.Copy to read from a file and then write the file to the response.

Serving a file with io.Copy

ServeContent & ServeFile both allow us to serve a single file.

Serving a file with http.ServeContent & http.ServeFile

The preferred method for serving files is http.FileServer.

Serving a file with http.FileServer

The preferred method for serving files is http.FileServer. We will use StripPrefix to facilitate the serving of files.

Serving a file with http.FileServer & http.StripPrefix

There is a special case: if you have an index.html file in a directory that FileServer is serving, then the FileServer will serve that file when only the root of the directory (“/”) is asked for

Creating a static file server with http.FileServer

Here are two pieces of code that you will sometimes see.

log.Fatal & http.Error

These hands-on exercises will help reinforce what you are learning

Hands-on exercises

Here are the solutions to the hands-on exercises.

Hands-on exercises - solutions

We can use the NotFoundHandler as the Handler for something that isn’t found

The http.NotFoundHandler
+ Deploying your site
2 lectures 10:08

When deploying a project to Google Cloud, it is good to have your domain with Google Domains. This will make the configuration of your domain easier

Buying a domain - google domains

Publishing your site on google cloud.

Deploying to google cloud
+ Creating state
13 lectures 01:20:11

HTTP does not have state built into it. You could say HTTP is stateless, though it has the tools necessary for you, as a developer, to create state. In this section, we’ll learn how to create state on the web.

State overview

We can pass values through the URL. We can retrieve them with req.FormValue

Passing values through the URL

When a form is submitted, we can pass the submitted values either through the request body payload or through the URL. If the form’s method attribute is post, then the values of the form are sent to the server through the request body’s payload. If the form’s method attribute is get, then the values of the form are sent to the server through the URL.

Passing values from forms

In many web programming languages, dealing with files can be a challenge. In Go, it’s easy. We’ll see in this video how to allow a user to upload a file. We’ll also see how to read that file and, if you want, create a new file to store on the server.

Uploading a file, reading the file, creating a file on the server

“When you make a POST request, you have to encode the data that forms the body of the request in some way.  HTML forms provide three methods for encoding.


On the web, we have a client / server architecture. Clients make requests, and servers write responses to those clients. The request and response are both just text that must conform to the rules of HTTP. Both the request & response have a start line, headers, and a body.

Redirects - overview

The definitive source for knowing which status code to use for HTTP/1.1 is RFC 7231.

Redirects - diagrams & documentation

Here is a code review of redirects in action.

Redirects - in practice

Cookies allow us to maintain state. We can write a unique ID to a cookie. When a client makes a request to a server at a particular domain, if there is a cookie from that particular domain on the client’s machine, the browser will include that cookie in the request. The server can then read that cookie, pull out the unique ID, and know which user is making the request. There are various methods to make this all secure, but the primary method is to use HTTPS.

Cookies - overview

How to write and read a cookie to and from a client’s machine.

Cookies - writing and reading

Two examples showing how (1) you can write multiple cookies and (2) you can create a counter.

Writing multiple cookies & hands-on exercise

How to create a counter to track how many times a user has been to your website domain using a cookie.

Hands-on exercise solution: creating a counter with cookies

To delete a cookie, set the “MaxAge” field to either zero or a negative number. You can expire a cookie by setting one of these two fields: Expires or MaxAge Expires sets the exact time when the cookie expires. Expires is Deprecated. MaxAge sets how long the cookie should live (in seconds).

Deleting a cookie
+ Creating sessions
9 lectures 01:02:34

In computer science, a session is an interactive information interchange, also known as a dialogue, a conversation or a meeting, between two or more communicating devices, or between a computer and user. A session is set up or established at a certain point in time, and then torn down at some later point.

An HTTP exchange between a browser and a server may include an HTTP cookie which identifies state using a unique ID which can be used to look up the user.

Each transaction in HTTP creates a separate connection. Maintaining session continuity between phases requires a session ID. The session ID is embedded within the <A HREF> or <FORM> links of dynamic web pages so that it is passed back to the server. The server then uses the session ID to ensure session continuity between transactions.

A unique ID session token is a unique identifier that is generated and sent from a server to a client. The client usually stores and sends the token as an HTTP cookie and/or sends it as a parameter in GET or POST queries. The reason to use session tokens is that the client only has to handle the identifier—all session data is stored on the server (usually in a database, to which the client does not have direct access) linked to that identifier.


A universally unique identifier (UUID) is an identifier standard used in software construction. A UUID is simply a 128-bit value. The meaning of each bit is defined by any of several variants. For human-readable display, many systems use a canonical format using hexadecimal text with inserted hyphen characters. For example: 123e4567-e89b-12d3-a456-426655440000 The intent of UUIDs is to enable distributed systems to uniquely identify information without significant central coordination. In this context the word unique should be taken to mean "practically unique" rather than "guaranteed unique". Since the identifiers have a finite size, it is possible for two differing items to share the same identifier. This is a form of hash collision. The identifier size and generation process need to be selected so as to make this sufficiently improbable in practice. Anyone can create a UUID and use it to identify something with reasonable confidence that the same identifier will never be unintentionally created by anyone to identify something else. Information labeled with UUIDs can therefore be later combined into a single database without needing to resolve identifier (ID) conflicts. Adoption of UUIDs is widespread with many computing platforms providing support for generating UUIDs and for parsing/generating their textual representation. Only after generating 1 billion UUIDs every second for the next 100 years would the probability of creating just one duplicate would be about 50%.

Universally unique identifier - UUID

Creating a session ID for looking up user info.

Your first session

Creating a user sign-up page. Processing the form submission. Storing information in our maps.


Bcrypt is a password hashing function designed by Niels Provos and David Mazières. Besides incorporating a salt to protect against rainbow table attacks, bcrypt is an adaptive function: over time, the iteration count can be increased to make it slower, so it remains resistant to brute-force search attacks even with increasing computation power. The bcrypt function is the default password hash algorithm for OpenBSD and other systems including some Linux distributions such as SUSE Linux. We will use bcrypt to encrypt user passwords before storing them.

Encrypt password with bcrypt

We will create a form that allows a user to login. We will then check the login credentials to see if the user successfully authenticates.


We will create the functionality to allow a user to logout. This will end the user’s session


We will add the ability for different users to have different permissions. These different permissions will allow some users to access some areas, while others can’t. For instance, if someone had “admin” rights, then they could access the “admin” areas.


We will create the ability for a user’s session to expire after a certain period of time. We will need to clear the user’s cookie, and remove the entry in the session’s map which stores that user’s session. In addition, we will want to clear out our session’s map on some interval. We will use the “MaxAge” field of the cookie to set the length of time, in seconds, that a cookie lasts.

Expire session
+ Amazon Web Services
7 lectures 54:36

We will look at some of the various parts of Amazon Web Services (AWS) including: EC2 (Elastic Compute Cloud), S3 (Simple Storage Service), RDS, DynamoDB, ElastiCache, Elastic BeanStalk, and Route 53. CLoud computing is covered, as is IAAS, PAAS, SAAS.


We will create a virtual machine running linux ubuntu on Amazon’s elastic cloud computing.

Creating a virtual server instance on AWS EC2

Uploading code to EC2 involves a few steps. First we will build our binary to run on the correct architecture and operating system. Then we will use secure copy to copy our binary to the remote server. After that, we will use secure shell to log into our remote server and run our code.

Hello World on AWS

To have an application continue running after our terminal session ends, we must complete a few steps. Specifically, we will be using systemd. systemd is an init system used in Linux distributions to bootstrap the user space and manage all processes. One of systemd's main goals is to unify basic Linux configurations and service behaviors across all distributions. As of 2015, most Linux distributions have adopted systemd as their default init system.

Persisting an application

For this hands-on exercise, deploy the code in "030_sessions/08_expire-session" and get it running on AWS.

Hands-on Exercise

For this hands-on exercise, deploy the code in "030_sessions/08_expire-session" and get it running on AWS.

Hands-on Solution

When we are finished working with machines, we need to terminate them. Failure to do this might result in billing.

Terminating AWS services
  • You must understand how to program with the Go programming language before taking this course. If you do not know how to program with Go, please take my course: "Learn How To Code: Google's Go (golang) Programming Language"

The Go programming language was created by Google to do what Google does: performant web applications at scale.

Open-sourced in 2009 and reaching version one in 2012, the Go programming language is the best choice for web development programming today.

Ruby on Rails, Python, Django, Node.js, PHP, and ASP all fall short.

Go is the most powerful, performant, and scalable programming language today for creating web applications, web API’s, microservices, and other distributed services.

In this course, you will gain a solid foundation in web development. You will learn all of the following and more:


  • networking architecture

  • the client / server architecture

  • the request / response pattern

  • the RFC standards defined by the IETF

  • the format of requests from clients and responses from servers


  • the role that templates play in server-side programming

  • how to work with templates from Go’s standard library

  • modifying data structures to work well with templates


  • the relationship between TCP and HTTP

  • how to build a TCP server which responds to HTTP requests

  • how to create a TCP server which acts as an in-memory database

  • how to create a restful TCP server that handles various routes and methods

  • the difference between a web server, a servemux, a multiplexer, and a mux

  • how to use a third-party server such as julien schmidt’s router

  • the importance of HTTP methods and status codes

The net/http package

  • streamlining your web development with the net/http package

  • the nuances of the net/http package

    • the handler interface

    • http.ListenAndServe

    • creating your own servemux

    • using the default servemux

    • http.Handle & http.Handler

    • http.Handlefunc, func(ResponseWriter, *Request), & http.HandlerFunc

    • http.ServeContent, http.ServeFile, & http.FileServer

    • http.StripPrefix

    • http.NotFoundHandler

State & Sessions

  • how to create state: UUID’s, cookies, values in URL’s, security

  • how to create sessions: login, permissions, logout

  • how to expire a session


  • how to purchase a domain

  • how to deploy an application to Google Cloud

Amazon Web Services

  • how to use Amazon Web Services (AWS)

  • how to create a virtual linux machine on AWS EC2 (Elastic Cloud Compute)

  • how to use secure shell (SSH) to manage a virtual machine

  • how to use secure copy (SCP) to transfer files to a virtual machine

  • what load balancers are and how to use them on AWS


  • how to use MySQL on AWS

  • how to connect a MySQL workbench to AWS


  • understanding CRUD

  • how to use MongoDB & Go

MVC (Model View Controller) Design Pattern

  • understanding the MVC design pattern

  • using the MVC design pattern


  • virtual machines vs containers

  • understanding the benefits of using Docker

  • Docker images, Docker containers, and Docker registries

  • implementing Docker and Go

  • deploying Docker and Go

Google Cloud

  • Google Cloud Storage

  • Google Cloud no-sql datastore

  • Google Cloud memcache

  • Google Cloud PAAS App Engine

Web Dev Toolkit

  • AJAX

  • JSON

  • json.Marhsal & json.Unmarshal

  • json.Encode & json.Decode

  • Hash message authentication code (HMAC)

  • Base64 encoding

  • Web storage

  • Context


  • JSON with Go using Tags

Building Applications

  • a photo blog

  • a twitter clone

By the end of this course, you will have mastered the fundamentals of web development.

My name is Todd McLeod. I am tenured faculty in Computer Information Technology at Fresno City College and adjunct faculty in Computer Science at California State University Fresno. I have taught enough students over 17 years to know that by the end of this course, you will be an outstanding web developer.

You will have the best skills available today.

You will know the best way to do web development today.

You will have the hottest, most demanded, and highest paid skills in the marketplace.

Join me in this outstanding course. Come learn best practices for web development. Sign up for this course now and open doors to a great future.

Who this course is for:
  • This is a university level introduction to web programming course.
  • This course is for individuals who know how to use the Go programming language.
  • This course is perfect for programmers wanting a thorough introduction to web development using the Go programming language.
  • This course is perfect for developers wanting to fill in gaps in their knowledge.