Creating Web Applications with Google App Engine, Cloud SQL, and Go/Golang
Status as of July 2018: About 75% finished
If you want to write database-backed applications using the Go language and Google Cloud SQL, you've come to the right place. I was hampered by the severe lack of end-to-end examples and by my ignorance of database administration. This book is an answer to that problem. It takes you through the creation of a simple to do database in Go, then adds a web front end to it.
If you're not an expert already, good!
This book is for you if you if you are not an expert in all of the following:
- Go
- Google App Engine
- MySQL
- Database administration at the command line
- Google Cloud SQL, and
- Writing database-backed web applications
It seems like any time I need to learn a new topic, say... writing Go web apps that use SQL, the book seems to think I'm already an expert in a number of other areas. Sure, I'd used MySQL, but I didn't know how to write a connection string for Google Cloud SQL in Go and couldn't find any complete example programs. Or maybe you've used Google App Engine and Datastore, but not Go or MySQL or Cloud SQL. It was not even obvious to me at first that you still need to run My SQL locally to develop, even though your database will eventually live in the cloud.
If you're anything like me, it is much more likely that you have a smattering of knowledge in one or two of these areas but nothing about some of the others. This books walks you through installing and configuring all of the tools you'll need, and it contains many complete example programs with absolutely nothing "left as an exercise for the reader".
Who's the audience for this book?
The audience for this book is working developers who need to create a working App Engine app, written in Go, and using Cloud SQL for the database back end, but who don't necessarily know a lot about any one of those areas. If you're in that position, you're the ideal customer for this book.
Note: This version is mostly oriented toward Mac and Linux users
This book shows you what to do every step of the way, and that's great for a beginner. The problem with this approach is that I don't have the time to create alternate instructions for Windows users for things such as configuring environment variables or exact directories for installing libraries and executable programs.
I can tell you this all works for a MacOS machine using the Bash interpreter and that I've tested it all many times. I also try to provide suggestions for non-MacOS environments when possible.
Contact me at [email protected] if you're a Windows developer and need better docs. If there's enough demand I'll get those sections written.
What this book shows
This book shows how to
- Install the Go SDK
- Set up your machine to write and run Go programs
- Download, install, and run MySQL on your development system (necessary for developing Google Cloud SQL applications)
- Sign up for a Google Developer account
- Sign up for Google App Engine
- Install the App Engine SDK
- Create a simple App Engine program
- Sign up for Google Cloud SQL account and configure it securely
- Create a database in Cloud SQL
- Create a table in Cloud SQL, both interactively and using command-line administration tools
- Populate that table, both interactively and using Golang code
What's special about this book?
This book is for people who know the basics, but who don't know the ins and outs of doing the adminstration work. It's one thing to read a tutorial. It's another thing to find out that you don't know what security measures to take, how to import the libraries you need, how Github integrates with App Engine, and so on.
It is notable because:
- Every step is described procedurally. For example, I don't just tell you to create a source directory for your Go apps, I give you the name of a specific directory to create.
- Instead of just telling you to run an install program, I tell you how to test for a successful installation afteward.
- Most examples are presented as complete projects, so you don't have to guess what to fill in.
- Each section has a brief explanation of the theory before presenting code or instructions, to make it easier for you to stay the course of the toolset changes its user interface.
- You should be able to learn by reading it on a trane or plane without being able to type in code right at that moment. Each section of the book is written and organized so that you can read it through like a tutorial, but then go back and reread it for conceptual parts just as quickly, using the tutorial material to illustrate and cement the concepts in your mind.
I understand concepts pretty quickly. But I am not a natural sysadmin/devops kind of person. Little about the process of creating a production App Engine app in Go using Google Cloud SQL was obvious to me. At the time of writing (fall 2015) there are no tutorials on the web that take you from account creation to a finished app. I see tutorials for using using Go with MySQL/Cloud SQL that assume you already know about database administration. The database administration tutorials don't have any mention of Go apps or the Google Developer Console. And often you are expected to know things that seem very basic, such as a good directory to place your Go source files, that were not at all obvious to me.
What you need to know
- Roughly what SQL databases do
- How to use the command line/terminal for your operating system
- Fundamental programming concepts such as file I/O, writing functions and using their return values, and variables
- How to create a simple "hello, world" app using a text editor and compile using the command line in Go
- Roughly what source code control systems like Github are for
Resources you'll need
- This book uses Google Cloud SQL, which is not free. That means you'll need some way to pay for an account, presumably a credit card. (The cost for a month or so is less then the cost of eating a single meal in a mainstream restaurant in the USA or Europe.)