Go Web Programming cover
welcome to this free extract from
an online version of the Manning book.
to read more
or

About this Book

published book

This book introduces the basic concepts of writing a web application using the Go programming language, from the ground up, using nothing other than the standard libraries. While there are sections that discuss other libraries and other topics, including testing and deploying web applications, the main goal of the book is to teach web programming using Go standard libraries only.

The reader is assumed to have basic Go programming skills and to know Go syntax. If you don’t know Go programming at all, I would advise you to check out Go in Action by William Kennedy with Brian Ketelsen and Erik St. Martin, also published by Manning (www.manning.com/books/go-in-action). Another good book to read is The Go Programming Language (Addison-Wesley 2015), by Alan Donovan and Brian Kernighan. Alternatively, there are plenty of free tutorials on Go, including the A Tour of Go from the Go website (tour.golang.org).

Roadmap

The book includes ten chapters and an appendix.

Chapter 1 introduces using Go for web applications, and discusses why it is a good choice for writing web applications. You’ll also learn about key concepts of what web applications are, including a brief introduction to HTTP.

Chapter 2 shows you how to build a typical web application with Go, taking you step by step through the creation of a simple internet forum web.

Chapter 3 gets into the details of handling HTTP requests using the net/http package. You’ll learn how to write a Go web server to listen to HTTP requests and how to incorporate handlers and handler functions that process those requests.

Chapter 4 continues with the details of handling HTTP requests—specifically, how Go allows you to process the requests and respond accordingly. You’ll also learn how to get data from HTML forms and how to use cookies.

Chapter 5 delves into the Go template engine provided in the text/template and html/template packages. You’ll learn about the various mechanisms provided by Go and about using layouts in Go.

Chapter 6 discusses storage strategies using Go. You’ll learn about storing data in memory using structs, in the filesystem using CSV and the gob binary format as well as using SQL and SQL mappers to access relational databases.

Chapter 7 shows you how to create web services using Go. You’ll learn how to create and parse XML as well as JSON with Go, and how a simple web service can be written using Go.

Chapter 8 gives insight into the ways you can test your Go web application at various levels, including unit testing, benchmark testing, and HTTP testing. This chapter also briefly discusses third-party testing libraries.

Chapter 9 talks about how you can leverage Go concurrency in your web application. You’ll learn about Go concurrency and how you can improve the performance of a photo-mosaic web application using Go concurrency.

Chapter 10 wraps up the book by showing how you can deploy your web application. You’ll learn how to deploy to standalone servers and to the cloud (Heroku and Google App Engine), as well as in Docker containers.

The appendix provides instructions for installing and setting up Go on different platforms.

Code conventions and downloads

This book contains many examples of source code both in numbered listings and inline with normal text. In both cases, source code is formatted in a fixed-width font like this to separate it from ordinary text. Sometimes code is in bold to highlight code that has changed from previous steps in the chapter or code that is discussed in surrounding text.

Also, colors are used to highlight code commands and code output:

curl -i 127.0.0.1:8080/write
HTTP/1.1 200 OK
Date: Tue, 13 Jan 2015 16:16:13 GMT
Content-Length: 95
Content-Type: text/html; charset=utf-8

<html>
<head><title>Go Web Programming</title></head>
<body><h1>Hello World</h1></body>
</html>

Print book readers who want to see this color code highlighting (and all figures in color) can go to www.manning.com/books/go-web-programming to register and get their free eBook in PDF, ePub, and Kindle formats.

Code samples used throughout the book are also available at www.manning.com/books/go-web-programming and at github.com/sausheong/gwp.

About the author

SAU SHEONG CHANG is now the Managing Director of Digital Technology at Singapore Power. Before that, he was a Director of Consumer Engineering at PayPal. He is active in the Ruby and Go developer communities, and has written books, contributed to open source projects, and spoken at meetups and conferences.

Author Online

Purchase of Go Web Programming includes free access to a private web forum run by Manning Publications; you can make comments about the book, ask technical questions, and receive help from the author and from other users. To access the forum and subscribe to it, point your web browser to www.manning.com/books/go-web-programming. This page provides information on how to get on the forum after you’re registered, what kind of help is available, and the rules of conduct on the forum.

Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the author can take place. It’s not a commitment to any specific amount of participation on the part of the author, whose contribution to the forum remains voluntary (and unpaid). We suggest you try asking the author some challenging questions lest his interest stray!

The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.

Get Go Web Programming
add to cart
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage