We need to display the user's book collection from previous selections. We'll pull all the books from the database and display them in the UI.
- [Instructor] Hi, and welcome!…In the previous video,…we replaced the default template engine…with a third-party library ace.…Now we need to display a user's book collection in the UI.…In this video, we'll update our website…to find all the books in the database…and render them in the template.…We'll start by updating our page objects…to include the selected books.…Next, we'll modify our index template…to show a table full of the books.…Finally, we'll make a call to the database…to get the correct results.…Let's get to it.…In our main.go file,…we want to return a list of books to the index template.…
Let's create a new struct called Book…which will represent our database object.…A Book should have an integer, PK, and strings…for Title, Author, and Classification.…Our page struct has gone largely unused…since section one of this series.…Let's replace the name and db status properties…with a slice of book objects.…In the root handler,…we can now remove all of our old page initialization code,…update the property initializers…
Go is on the rise. This open-source programming language (created by Google!) comes with a strong and accessible standard library, and provides a growing ecosystem of tools, libraries, and frameworks that can help you build web applications fast. Go for Web Development gets you started with the language, opening with the classic "Hello world" exercise and culminating in a web application with a strongly designed database back end, useful middleware, UI with an intelligent search function, multi-user authentication, and more.
First, learn how to build a web server with Go's extensive standard library. Explore the concepts behind a single-page web application and learn how to create a dynamic user interface, manipulate a database, and use powerful encryption algorithms to implement an authentication system. Next, you'll incorporate more functionality by calling out to external libraries from the database. Finally, it all comes together into an optimized package you can deploy into the wild with Heroku.
- Creating a route in Go
- Using templates
- Building database connections
- Collecting data
- Using web middleware
- Using the Ace template engine
- Integrating HTTP routers like gorilla/mux
- Authenticating users
- Optimizing a Go codebase