Building Web Applications With Go (part 2)

in #steemstem8 years ago (edited)

What Will You Learn?

  • You will learn how to effectively use the Go Template Engine
  • You will learn how to extend a Go application by adding static files like CSS and JavaScript
  • You will learn how to properly format a Go Template partial using blocks

Requirements

  • A fair knowledge of HTTP
  • Basic HTML and CSS experience
  • Code from Part 1
  • Go 1.6+ installed on your machine with the GOPATH and GOROOT setup properly

Difficulty

  • Basic

Description

In this video tutorial, we continue to extend out our Go Web Application. By making use of the robust Template engine that is standard in the Go language, we can create a front end that makes use of static files, images, JavaScript and CSS (Cascading Style Sheets). We can also use the template engine to create partials to effectively eliminate code reuse for our front end.

First, we use initializr to bring in Jquery, Bootstrap, Google Fonts and a basic HTML document. Then we strip this document of all of the things that we do not need and move the header and footer into their own files. We define these headers and footers as templates which allows us to dynamically serve them onto any page that needs them. We also add a few lines to our main Go file to further serve these static files so that the browser can fine them properly. We also build out a small but functional navigation bar for our application that changes its link's routes based on the page that it is pointed at. Finally, we finish by combining all of these HTML partials to make our dynamic pages which allows us to serve the content from our Go web application's data store.

The source code for this project can be found here

Video Tutorial

Curriculum

Sort:  

well done tensor, once again!

Thanks. These are older videos, but they still are relevant today and I really just want to get them onto the platform for when I expand on them in the future.

Coin Marketplace

STEEM 0.04
TRX 0.32
JST 0.083
BTC 60866.94
ETH 1568.75
USDT 1.00
SBD 0.50