This chapter covers
- Creating a gRPC client
- Using templates in Go to fill an HTML page
- Calling an existing backend
When you have data that you want to show, there are two main questions to answer: What should you show, and how should you show it? While answering the first question is part of understanding the problem, knowing how to present the results, and making them clear, is often a requirement to make the solution meaningful. As computer scientists, we deal with huge amounts of data, most of which is mundane to the people who live next door, the other school parents, or the person in front of us at the grocery store. In chapter 5, we explained how using icons made the game Wordle (and our game Gordle) more entertaining than a display of mere numbers. Being able to clearly give a picture of the raw data is so important that the Golang developers introduced the text/template
package to support this in the first version of the language. The goal of this package and of its sibling http/template
is to generate enriched text output based on the contents of some data. Most of the time, the data needs to be nicely formatted—add a tab here, insert a new line there, or add this or that tag—and we’ll explain why other Golang tools aren’t better at this task than templates.