/goblueprints

Source code for Go Programming Blueprints

Primary LanguageGoMIT LicenseMIT

Go Programming Blueprints

Go Blueprints by Mat Ryer book cover

This is the official source code repository for the book. You are welcome to browse this repository and use the issues tab to report any problems or ask any questions.

  • Feel free to copy and paste from the repository where appropriate, although typing the code out will surely do more for the learning experience
  • If you are enjoying the book, please tell others by reviewing the book on Amazon

Get the book

Projects

Throughout the book many projects, programs and packages are developed, including:

  • Chat application web application that lets people have conversations in their browsers.
  • Tracer package package that provides tracing capabilities for Go programs. Built for illustration purposes, in production environments consider using log.Logger from the standard library instead.
  • Domain finder program that helps you find the perfect domain name for your projects, including whether they're available or not. Depends on a series of subprograms that do its bidding.
  • Thesaurus package that provides an interface and an implementation for Big Huge Thesaurus that allows you to lookup synonyms of words.
  • Meander package that provides random event recommendations with associated web application
  • Backup program for periodically backing up your source code.

Chapters

Each chapter has its own section which it is recommended that you read before embarking on the chapter itself, as updates, tweaks, bug fixes, additional notes and tips will be outlined here.

Chapter 1

Chapter 2

Notes:

  • Page 53: w.Header.Set should be w.Header().Set since Header is a function on http.ResponseWriter.

Chapter 3

Notes:

  • Page 81: For Gravatar to work, you need to hash the email address, not the user's name: io.WriteString(m, strings.ToLower(user.Email())) - Thanks @lozandier

Other minor things:

  • Page 78: Autocompleted typo: gravatarAvitar should be gravatarAvatar - you can name your variables anything you like, but it's nice for them to be spelled correctly. - Thanks @lozandier
  • Page 83: The HTML <label> is not properly attached to the associated <input> - View Diff - Thanks @crbrox

Chapter 4

Notes:

  • BigHuge is mistyped in a few places as BigHugh. I don't know who Big Hugh is, but I'm sure he's very nice. Either way, he's a little unwelcome in Chapter 4, so you should consistently type big HUGE - Thanks @OAGr
  • Page 112: Sometimes data.Noun and data.Verb are nil, which causes a panic. Make your code a little more bulletproof by first checking if they're == nil before trying to access the Syn field. See Issue #11 for a solution. Thanks @OAGr

Chapter 5

Notes:

Chapter 6

  • Struct tags are written like this: json:"title"
  • Browse the Source code

Chapter 7

Chapter 8

Appendix A