Go Web Development Cookbook
Build full-stack web applications with Go
Arpit Aggarwal
BIRMINGHAM - MUMBAI
Go Web Development Cookbook
Copyright 2018 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: Ashwin Nair
Acquisition Editor: Denim Pinto
Content Development Editor: Nikhil Borkar
Technical Editor: Jash Bavishi
Copy Editor: Safis Editing
Project Coordinator: Ulhas Kambali
Proofreader: Safis Editing
Indexer: Mariammal Chettiyar
Graphics: Tania Dutta
Production Coordinator: Aparna Bhagat
First published: April 2018
Production reference: 1200418
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78728-674-0
www.packtpub.com
To my mother, Anita Aggarwal, and to the memory of my father, Anil Aggarwal,
for their sacrifices and for exemplifying the power of determination
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
PacktPub.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.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details.
At www.PacktPub.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
Arpit Aggarwal is a programmer with over 7 years of industry experience in software analysis, design, effort estimation, development, troubleshooting, testing, and supporting web applications. He is among the top contributors of StackOverflow with more than 9,000 reputation and more than 100 badges in multiple areas such as Java, Scala, Go, Spring, Spring-MVC, GiT, Angular, Unit Testing, Web Services, and Docker, and has written many technical articles for Java Code Geeks, System Code Geeks, Web Code Geeks, and DZone.
About the reviewer
Anshul Joshi is a data science professional with experience primarily in data munging, recommendation systems, predictive modeling, and distributed computing. He has worked on Spark and Hadoop ecosystems. He is a deep learning and AI enthusiast and holds degrees in computer science and data analytics. Most of the time, he can be caught exploring GitHub or trying anything new that he can get his hands on.
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
Go is an open source programming language that is designed to scale and supports concurrency at the language level, which allows developers to write large concurrent web applications with ease.
From creating a web application to deploying it on AWS, this will be a one-stop guide to learn w eb development in Go. Whether you are new to programming or a professional developer, the book will get you up to speed on web development in Go.
The book will focus on writing modular code in Go and contains in-depth informative recipes building the base one step at a time. You will be taken through concepts and recipes such as creating a server, working with HTML Forms, session and error handling, SQL and NoSQL databases, Beego, creating and securing RESTful web services, creating, unit testing and debugging WebSockets, and creating Go Docker containers and deploying them on AWS.
By the end of the book, you will be able to apply your newly-learned skills in Go to create and explore web applications in any domain.
Who this book is for
This book is intended for developers who want to use Go to write large concurrent web applications. Readers with some familiarity with Go will find this book the most beneficial.
What this book covers
, Creating Your First Server in Go , explains how to write and interact with HTTP and TCP servers, optimize server responses with GZIP compression, and implement routing and logging in a Go web application.
, Working with Templates, Static Files, and HTML Forms , covers how to create HTML templates; serve static resources from the filesystem; create, read, and validate HTML Forms; and implement a simple user authentication for a Go web application.
, Working with Sessions, Error Handling, and Caching in Go , explores implementing HTTP sessions, HTTP cookies, error handling, and caching and managing HTTP sessions using Redis, which is required for a web application deployed across multiple data centers.
, Writing and Consuming RESTful Web Services in Go , explains how to write RESTful web services, version them, and create AngularJS with TypeScript 2, ReactJS, and VueJS clients to consume them.
, Working with SQL and NoSQL Databases , goes through implementing CRUD operations with MySQL and MongoDB databases in a Go web application.
, Writing Microservices in Go Using Micro a Microservice Toolkit
Next page