Creating a website in Go

Do you remember the keyValue.go application from Chapter 4, The Uses of Composite Types, and kvSaveLoad.go from Chapter 8, Telling a UNIX System What to Do? In this section, you will learn how to create a web interface for the keyValue.go application using the capabilities of the standard Go library. The name of the new Go source code file is kvWeb.go, and it is going to be presented in six parts.

The first difference between the Go code for kvWeb.go and www.go, developed earlier in this chapter, is that kvWeb.go uses the http.NewServeMux type to deal with HTTP requests because it is much more versatile for non-trivial web applications.

The first part of kvWeb.go is as follows:

package main import ( "encoding/gob" ...

Get Mastering Go - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.