Hands-On Full Stack Development with Go
Build full stack web applications with Go, React, Gin, and GopherJS
Mina Andrawos
BIRMINGHAM - MUMBAI
Hands-On Full Stack Development with Go
Copyright 2019 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor: Aaron Lazar
Acquisition Editor: Shahnish Khan
Content Development Editor: Zeeyan Pinheiro
Technical Editor: Sabaah Navlekar
Copy Editor: Safis Editing
Project Coordinator: Vaidehi Sawant
Proofreader: Safis Editing
Indexer: Tejal Daruwale Soni
Graphics: Alishon Mendonsa
Production Coordinator: Jyoti Chauhan
First published: March 2019
Production reference: 1260319
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78913-075-1
www.packtpub.com
For Nabil, Mervat, Catherine, and Fady.
Thanks to all of my family for their amazing support and continuous encouragement.
Mina Andrawos
mapt.io
Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Mapt is fully searchable
Copy and paste, print, and bookmark content
Packt.com
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at customercare@packtpub.com for more details.
At www.packt.com , you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Contributors
About the author
Mina Andrawos is an experienced engineer who has acquired deep experience in Go from using it personally and professionally. He regularly authors articles and tutorials about the language, and also shares Go's open source projects. He has written numerous Go applications with varying degrees of complexity. Other than Go, he has skills in Java, C#, Python, and C++. Besides software development, he has working experience of scrum mastering, sales engineering, and software product management.
About the reviewer
Pankaj Khairnar is a founder and CEO of Scalent Infotech Pvt. Ltd. (a Golang-specialized development company.) In his career of over 12 years, he has developed many highly scalable platforms for various domains such as digital advertising, the Internet of Things (IoT), and e-commerce. Pankaj always likes to explore and implement new cutting-edge technologies.
I would like to thank Anant Haral for helping by re-reviewing all the chapters and testing all the examples again.
Packt is searching for authors like you
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Preface
The Go programming language has been rapidly adopted by developers for building web applications. With its impressive performance and ease of development, Go enjoys the support of a wide variety of open source frameworks for building scalable and high-performance web services and applications. This book is a comprehensive guide that covers all aspects of full stack development with Go. As you progress through the book, you'll gradually build an online musical instrument store application from scratch.
This clearly written, example-rich book begins with a practical exposure to Go development, by covering Go's building blocks, as well as Go's powerful concurrency features. We'll then explore the popular React framework, and work on building the frontend of our application with it. From there, you will build RESTful Web APIs utilizing the Gin framework, which is a very powerful and popular Go framework for Web APIs. After that, we will dive deeper into important software backend concepts, such as connecting to the database using an object-relational mapping (ORM), designing routes for your services, securing your services, and even charging credit cards using the popular Stripe API. We will also cover how to test and benchmark your applications efficiently in a production environment. In the concluding chapters, we will cover isomorphic development in pure Go by learning about GopherJS.
By the end of the book, you will be confident in taking on full stack web applications in Go.
Who this book is for
This book will appeal to developers who are planning to start building functional full stack web applications in Go. Basic knowledge of the Go language and JavaScript is expected. Some knowledge of HTML and CSS is also expected. The book targets web developers who are looking to move to the Go language.
What this book covers
, Welcome to Full Stack Go , provides an introduction to the topics covered in the book, as well as an overview of the architecture of the application that will be built throughout the book. This chapter also provides us with a glimpse of what to expect from the book.
, Building Blocks of the Go Language , introduces us to the building blocks of the Go language, and how to utilize them to build simple applications. It starts by covering Go's syntax for variables, conditional statements, loops, and functions. From there, it covers how to construct data structures in Go, and how to attach methods to them. It then concludes by focusing on learning how to write interfaces that can describe the behaviors of our program.
Next page