Go: Building Web Applications

Build real-world, production-ready solutions by harnessing the powerful features of Go
Preview in Mapt

Go: Building Web Applications

Nathan Kozyra, Mat Ryer

3 customer reviews
Build real-world, production-ready solutions by harnessing the powerful features of Go

Quick links: > What will you learn?> Table of content> Product reviews

Mapt Subscription
FREE
$29.99/m after trial
eBook
$47.60
RRP $67.99
Save 29%
Print + eBook
$84.99
RRP $84.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$47.60
$84.99
$29.99 p/m after trial
RRP $67.99
RRP $84.99
Subscription
eBook
Print + eBook
Start 14 Day Trial

Frequently bought together


Go: Building Web Applications Book Cover
Go: Building Web Applications
$ 67.99
$ 47.60
Go: Design Patterns for Real-World Projects Book Cover
Go: Design Patterns for Real-World Projects
$ 71.99
$ 50.40
Buy 2 for $35.00
Save $104.98
Add to Cart

Book Details

ISBN 139781787123496
Paperback665 pages

Book Description

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. It is a statically typed language with syntax loosely derived from that of C, adding garbage collection, type safety, some dynamic-typing capabilities, additional built-in types such as variable-length arrays and key-value maps, and a large standard library.

This course starts with a walkthrough of the topics most critical to anyone building a new web application. Whether it’s keeping your application secure, connecting to your database, enabling token-based authentication, or utilizing logic-less templates, this course has you covered.

Scale, performance, and high availability lie at the heart of the projects, and the lessons learned throughout this course will arm you with everything you need to build world-class solutions. It will also take you through the history of concurrency, how Go utilizes it, how Go differs from other languages, and the features and structures of Go's concurrency core. It will make you feel comfortable designing a safe, data-consistent, and high-performance concurrent application in Go.

This course is an invaluable resource to help you understand Go's powerful features to build simple, reliable, secure, and efficient web applications.

This Learning Path combines some of the best that Packt has to offer in one complete, curated package. It includes content from the following Packt products:

Table of Contents

Chapter 1: Introducing and Setting Up Go
Installing Go
Structuring a project
Importing packages
Introducing the net package
Hello, Web
Summary
Chapter 2: Serving and Routing
Serving files directly
Basic routing
Using more complex routing with Gorilla
Redirecting requests
Serving basic errors
Summary
Chapter 3: Connecting to Data
Connecting to a database
Using GUID for prettier URLs
Handling 404s
Summary
Chapter 4: Using Templates
Introducing templates, context, and visibility
HTML templates and text templates
Displaying variables and security
Using logic and control structures
Summary
Chapter 5: Frontend Integration with RESTful APIs
Setting up the basic API endpoint
RESTful architecture and best practices
Creating our first API endpoint
Implementing security
Creating data with POST
Modifying data with PUT
Summary
Chapter 6: Sessions and Cookies
Setting cookies
Capturing user information
Initiating a server-side session
Summary
Chapter 7: Microservices and Communication
Introducing the microservice approach
Pros and cons of utilizing microservices
Understanding the heart of microservices
Communicating between microservices
Putting a message on the wire
Reading from another service
Summary
Chapter 8: Logging and Testing
Introducing logging in Go
Logging to IO
Formatting your output
Using panics and fatal errors
Introducing testing in Go
Summary
Chapter 9: Security
HTTPS everywhere – implementing TLS
Preventing SQL injection
Protecting against XSS
Preventing cross-site request forgery (CSRF)
Securing cookies
Using the secure middleware
Summary
Chapter 10: Caching, Proxies and Improved Performance
Identifying bottlenecks
Implementing reverse proxies
Implementing caching strategies
Implementing HTTP/2
Summary
Chapter 11: Chat Application with Web Sockets
A simple web server
Modeling a chat room and clients on the server
Building an HTML and JavaScript chat client
Tracing code to get a look under the hood
Summary
Chapter 12: Adding Authentication
Handlers all the way down
Making a pretty social sign-in page
Endpoints with dynamic paths
OAuth2
Tell the authentication providers about your app
Implementing external logging in
Summary
Chapter 13: Three Ways to Implement Profile Pictures
Avatars from the authentication server
Implementing Gravatar
Uploading an avatar picture
Combining all three implementations
Summary
Chapter 14: Command-line Tools to Find Domain Names
Pipe design for command-line tools
Five simple programs
Composing all five programs
Summary
Chapter 15: Building Distributed Systems and Working with Flexible Data
System design
Installing the environment
Votes from Twitter
Counting votes
Running our solution
Summary
Chapter 16: Exposing Data and Functionality through a RESTful Data Web Service API
RESTful API design
Sharing data between handlers
Wrapping handler functions
Responding
Understanding the request
A simple main function to serve our API
Handling endpoints
A web client that consumes the API
Running the solution
Summary
Chapter 17: Random Recommendations Web Service
Project overview
Representing data in code
Generating random recommendations
Summary
Chapter 18: Filesystem Backup
Solution design
Backup package
The user command-line tool
The daemon backup tool
Testing our solution
Summary
Chapter 19: An Introduction to Concurrency in Go
Introducing goroutines
Implementing the defer control mechanism
Understanding goroutines versus coroutines
Implementing channels
Closures and goroutines
Building a web spider using goroutines and channels
Summary
Chapter 20: Understanding the Concurrency Model
Understanding the working of goroutines
Synchronous versus asynchronous goroutines
Visualizing concurrency
RSS in action
A little bit about CSP
Go and the actor model
Object orientation
Using concurrency
Managing threads
Using sync and mutexes to lock data
Summary
Chapter 21: Developing a Concurrent Strategy
Applying efficiency in complex concurrency
Identifying race conditions with race detection
Synchronizing our concurrent operations
The project – multiuser appointment calendar
A multiuser Appointments Calendar
A note on style
A note on immutability
Summary
Chapter 22: Data Integrity in an Application
Getting deeper with mutexes and sync
The cost of goroutines
Working with files
Getting low – implementing C
Distributed Go
Some common consistency models
Using memcached
Summary
Chapter 23: Locks, Blocks, and Better Channels
Understanding blocking methods in Go
Cleaning up goroutines
Creating channels of channels
Pprof – yet another awesome tool
Handling deadlocks and errors
Summary
Chapter 24: C10K – A Non-blocking Web Server in Go
Attacking the C10K problem
Building our C10K web server
Serving pages
Multithreading and leveraging multiple cores
Exploring our web server
Summary
Chapter 25: Performance and Scalability
High performance in Go
Using the App Engine
Distributed Go
Some helpful libraries
Memory preservation
Summary
Chapter 26: Concurrent Application Architecture
Designing our concurrent application
Identifying our requirements
Using NoSQL as a data store in Go
Monitoring filesystem changes
Managing logfiles
Handling configuration files
Detecting file changes
Backing up our files
Designing our web interface
Reverting a file's history – command line
Checking the health of our server
Summary
Chapter 27: Logging and Testing Concurrency in Go
Handling errors and logging
Using the log4go package for robust logging
Using the runtime package for granular stack traces
Summary
Chapter 28: Advanced Concurrency and Best Practices
Going beyond the basics with channels
Building workers
Implementing nil channel blocks
Implementing more granular control over goroutines with tomb
Timing out with channels
Building a load balancer with concurrent patterns
Choosing unidirectional and bidirectional channels
Using an indeterminate channel type
Using Go with unit testing
Using Google App Engine
Utilizing best practices
Summary

What You Will Learn

  • Build a fully featured REST API to enable client-side single page apps
  • Utilize TLS to build reliable and secure sites
  • Learn to apply the nuances of the Go language to implement a wide range of start-up quality projects
  • Create websites and data services capable of massive scale using Go's net/http package, exploring RESTful patterns as well as low-latency WebSocket APIs
  • Interact with a variety of remote web services to consume capabilities ranging from authentication and authorization to a fully functioning thesaurus
  • Explore the core syntaxes and language features that enable concurrency in Go
  • Understand when and where to use concurrency to keep data consistent and applications non-blocking, responsive, and reliable
  • Utilize advanced concurrency patterns and best practices to stay low-level without compromising the simplicity of Go itself

Authors

Table of Contents

Chapter 1: Introducing and Setting Up Go
Installing Go
Structuring a project
Importing packages
Introducing the net package
Hello, Web
Summary
Chapter 2: Serving and Routing
Serving files directly
Basic routing
Using more complex routing with Gorilla
Redirecting requests
Serving basic errors
Summary
Chapter 3: Connecting to Data
Connecting to a database
Using GUID for prettier URLs
Handling 404s
Summary
Chapter 4: Using Templates
Introducing templates, context, and visibility
HTML templates and text templates
Displaying variables and security
Using logic and control structures
Summary
Chapter 5: Frontend Integration with RESTful APIs
Setting up the basic API endpoint
RESTful architecture and best practices
Creating our first API endpoint
Implementing security
Creating data with POST
Modifying data with PUT
Summary
Chapter 6: Sessions and Cookies
Setting cookies
Capturing user information
Initiating a server-side session
Summary
Chapter 7: Microservices and Communication
Introducing the microservice approach
Pros and cons of utilizing microservices
Understanding the heart of microservices
Communicating between microservices
Putting a message on the wire
Reading from another service
Summary
Chapter 8: Logging and Testing
Introducing logging in Go
Logging to IO
Formatting your output
Using panics and fatal errors
Introducing testing in Go
Summary
Chapter 9: Security
HTTPS everywhere – implementing TLS
Preventing SQL injection
Protecting against XSS
Preventing cross-site request forgery (CSRF)
Securing cookies
Using the secure middleware
Summary
Chapter 10: Caching, Proxies and Improved Performance
Identifying bottlenecks
Implementing reverse proxies
Implementing caching strategies
Implementing HTTP/2
Summary
Chapter 11: Chat Application with Web Sockets
A simple web server
Modeling a chat room and clients on the server
Building an HTML and JavaScript chat client
Tracing code to get a look under the hood
Summary
Chapter 12: Adding Authentication
Handlers all the way down
Making a pretty social sign-in page
Endpoints with dynamic paths
OAuth2
Tell the authentication providers about your app
Implementing external logging in
Summary
Chapter 13: Three Ways to Implement Profile Pictures
Avatars from the authentication server
Implementing Gravatar
Uploading an avatar picture
Combining all three implementations
Summary
Chapter 14: Command-line Tools to Find Domain Names
Pipe design for command-line tools
Five simple programs
Composing all five programs
Summary
Chapter 15: Building Distributed Systems and Working with Flexible Data
System design
Installing the environment
Votes from Twitter
Counting votes
Running our solution
Summary
Chapter 16: Exposing Data and Functionality through a RESTful Data Web Service API
RESTful API design
Sharing data between handlers
Wrapping handler functions
Responding
Understanding the request
A simple main function to serve our API
Handling endpoints
A web client that consumes the API
Running the solution
Summary
Chapter 17: Random Recommendations Web Service
Project overview
Representing data in code
Generating random recommendations
Summary
Chapter 18: Filesystem Backup
Solution design
Backup package
The user command-line tool
The daemon backup tool
Testing our solution
Summary
Chapter 19: An Introduction to Concurrency in Go
Introducing goroutines
Implementing the defer control mechanism
Understanding goroutines versus coroutines
Implementing channels
Closures and goroutines
Building a web spider using goroutines and channels
Summary
Chapter 20: Understanding the Concurrency Model
Understanding the working of goroutines
Synchronous versus asynchronous goroutines
Visualizing concurrency
RSS in action
A little bit about CSP
Go and the actor model
Object orientation
Using concurrency
Managing threads
Using sync and mutexes to lock data
Summary
Chapter 21: Developing a Concurrent Strategy
Applying efficiency in complex concurrency
Identifying race conditions with race detection
Synchronizing our concurrent operations
The project – multiuser appointment calendar
A multiuser Appointments Calendar
A note on style
A note on immutability
Summary
Chapter 22: Data Integrity in an Application
Getting deeper with mutexes and sync
The cost of goroutines
Working with files
Getting low – implementing C
Distributed Go
Some common consistency models
Using memcached
Summary
Chapter 23: Locks, Blocks, and Better Channels
Understanding blocking methods in Go
Cleaning up goroutines
Creating channels of channels
Pprof – yet another awesome tool
Handling deadlocks and errors
Summary
Chapter 24: C10K – A Non-blocking Web Server in Go
Attacking the C10K problem
Building our C10K web server
Serving pages
Multithreading and leveraging multiple cores
Exploring our web server
Summary
Chapter 25: Performance and Scalability
High performance in Go
Using the App Engine
Distributed Go
Some helpful libraries
Memory preservation
Summary
Chapter 26: Concurrent Application Architecture
Designing our concurrent application
Identifying our requirements
Using NoSQL as a data store in Go
Monitoring filesystem changes
Managing logfiles
Handling configuration files
Detecting file changes
Backing up our files
Designing our web interface
Reverting a file's history – command line
Checking the health of our server
Summary
Chapter 27: Logging and Testing Concurrency in Go
Handling errors and logging
Using the log4go package for robust logging
Using the runtime package for granular stack traces
Summary
Chapter 28: Advanced Concurrency and Best Practices
Going beyond the basics with channels
Building workers
Implementing nil channel blocks
Implementing more granular control over goroutines with tomb
Timing out with channels
Building a load balancer with concurrent patterns
Choosing unidirectional and bidirectional channels
Using an indeterminate channel type
Using Go with unit testing
Using Google App Engine
Utilizing best practices
Summary

Book Details

ISBN 139781787123496
Paperback665 pages
Read More
From 3 reviews

Read More Reviews

Recommended for You

Go: Design Patterns for Real-World Projects Book Cover
Go: Design Patterns for Real-World Projects
$ 71.99
$ 50.40
Learning DevOps: Continuously Deliver Better Software Book Cover
Learning DevOps: Continuously Deliver Better Software
$ 67.99
$ 47.60
Python: Master the Art of Design Patterns Book Cover
Python: Master the Art of Design Patterns
$ 67.99
$ 47.60
Python: Penetration Testing for Developers Book Cover
Python: Penetration Testing for Developers
$ 67.99
$ 47.60
JavaScript: Functional Programming for JavaScript Developers Book Cover
JavaScript: Functional Programming for JavaScript Developers
$ 63.99
$ 44.80
Building RESTful Web services with Go Book Cover
Building RESTful Web services with Go
$ 31.99
$ 22.40