Cover Page....2
Table of Contents....3
Preface....5
Part 1: Building a Golang Backend....13
Chapter 1: Building the Database and Model....14
Technical requirements....15
Installing Docker....15
Setting up Postgres....16
Designing the database....18
Installing sqlc....21
Using sqlc....23
Setting up the database....26
Generating CRUD with sqlc....28
Building the makefile....34
Summary....35
Chapter 2: Application Logging....37
Technical requirements....37
Exploring Go standard logging....37
Using golog....40
Local logging....43
Writing log messages to the logging server....45
Configuring multiple outputs....48
Summary....51
Chapter 3: Application Metrics and Tracing....52
Technical requirements....52
Understanding OpenTelemetry....53
Tracing applications....56
Integrating the Jaeger SDK....59
Adding metrics using Prometheus....67
Running docker-compose....76
Summary....78
Part 2:Serving Web Content....79
Chapter 4: Serving and Embedding HTML Content....80
Technical requirements....80
Handling HTTP functions and Gorilla Mux....81
Rendering static content....90
Rendering dynamic content....93
Using Go embed to bundle your content....97
Summary....101
Chapter 5: Securing the Backend and Middleware....102
Technical requirements....102
Adding authentication....103
Adding middleware....108
Adding cookies and sessions....110
Summary....116
Chapter 6: Moving to API-First....117
Technical requirements....117
Structuring an application....118
Exposing our REST API....122
Converting to and from JSON....128
Reporting errors with JSON....133
Summary....136
Part 3:Single-Page Apps with Vue and Go....137
Chapter 7: Frontend Frameworks....138
Technical requirements....138
Server-side rendering versus single-page apps....139
Introducing React, Vue, and more....139
Creating a Vue app....143
Application and components....144
Using Vue Router to move around....150
Summary....154
Chapter 8: Frontend Libraries....155
Technical requirements....155
Understanding Vuetify....156
Setting up Vuetify....156
Using UI components....158
Understanding Buefy....160
Bulma sample....160
Setting up Buefy....162
UI components....163
Validating data entry with Vuelidate....164
Better input handling with Cleave.JS....169
Summary....171
Chapter 9: Tailwind, Middleware, and CORS....172
Technical requirements....172
Introducing Tailwind....172
Consuming your Golang APIs....178
CORS for secure applications....184
Creating Vue middleware....187
Summary....189
Chapter 10: Session Management....190
Technical requirements....190
Session management and JWTs....190
(Re)introducing Vue Router....200
Navigation guards....201
Defaults and error pages....204
Summary....205
Part 4:Release and Deployment....206
Chapter 11: Feature Flags....207
Technical requirements....207
An introduction to feature flags....207
Feature flag configuration....208
Use cases for using feature flags....210
The high-level architecture of feature flags....213
Integration of the feature flag....213
Summary....221
Chapter 12: Building Continuous Integration....223
Technical requirements....223
Importance of CI....223
GitHub Actions....229
Publishing Docker images....234
GitHub Packages....235
Summary....241
Chapter 13: Dockerizing an Application....243
Technical requirements....243
Installing Docker....243
Using Docker....245
Docker images....246
Running images as containers....251
Building and packaging images....254
Docker Compose....258
Summary....260
Chapter 14: Cloud Deployment....262
Technical requirements....262
AWS refresher....263
Understanding and using Terraform....270
Terraform basic commands....272
Coding in Terraform....278
Terraform examples....281
Summary....294
Index....296
Why subscribe?....312
Other Books You May Enjoy....313
Packt is searching for authors like you....317
Download a free PDF copy of this book....318
Go is a modern programming language with capabilities to enable high-performance app development. With its growing web framework ecosystem, Go is a preferred choice for building complete web apps. This practical guide will enable you to take your Go skills to the next level building full stack apps.
This book walks you through creating and developing a complete modern web service from auth, middleware, server-side rendering, databases, and modern frontend frameworks and Go-powered APIs. You'll start by structuring the app and important aspects such as networking, before integrating all the different parts together to build a complete web product. Next, you'll learn how to build and ship a complete product by starting with the fundamental building blocks of creating a Go backend. You'll apply best practices for cookies, APIs, and security, and level up your skills with the fastest growing frontend framework, Vue. Once your full stack application is ready, you'll understand how to push the app to production and be prepared to serve customers and share it with the world.
By the end of this book, you'll have learned how to build and ship secure, scalable, and complete products and how to combine Golang with existing products using best practices.
This book is for Go programmers who want to combine the power of the Go language with modern web development technologies to build complete web apps from frontend to backend. The book assumes beginner-level knowledge of HTML, CSS, and the web.