Leanpub Header

Skip to main content

How Do I Write And Deploy Simple Web Apps With Go?

A comprehensive tutorial.

Minimum price

$7.99

$9.99

You pay

$9.99

Author earns

$7.99
$

...Or Buy With Credits!

You can get credits with a paid monthly or annual Reader Membership, or you can buy them here.
PDF
EPUB
WEB
238
Readers
122
Pages
About

About

About the Book

The aim of the book is to get Go newbies started with developing and deploying web applications written using the Go programming language. By the time you finish reading the book, you would have developed and deployed many fun Go web apps on Heroku and Google App Engine.

You will learn to:

  • create static sites with Go
  • consume JSON apis with a Go web app
  • interact with Google apis with a Go web app
  • use MongoDB with Go on the web and 
  • use Martini the Go web framework.

Author

About the Author

Satish Talim

Satish Talim is the founder of RubyLearning, that helps Ruby programmers become awesome! He has more than 40 years of industrial experience and is a board member at Josh Software Pvt. Ltd. and Maybole Technologies Pvt. Ltd.

He is a trustee on the Emerging Technology Trust that organizes conferences in India like GopherConIndia and RubyConfIndia.

He has published many books on Amazon and was awarded Ruby's Top Teacher in 2008 and the winner of the Shorty Award in Education in 2009.

Follow @indianguru on Twitter or email him at satish@rubylearning.org

Contents

Table of Contents

Preface

  1. Who is the eBook for?
  2. Acknowledgements
  3. How to Use This eBook
  4. Using Code Examples
  5. Getting the Code
  6. How to Contact Me
  7. Thanks

1.Go Code Organization

  1. 1.1Workspaces
  2. 1.2The GOPATH environment variable
  3. 1.3Package paths
  4. Tip

2.A basic Go web app

  1. Exercise

3.Static Sites with Go

4.Using a Web Service - JSON with Go

  1. 4.1hosttip.info service

5.Package template

  1. 5.1struct
  2. 5.2array
  3. 5.3slice
  4. 5.4text/template
  5. 5.4.1Variables
  6. 5.5html/template
  7. 5.5.1Modify dosasite.go to use templates
  8. 5.6Handling Forms
  9. 5.7Web app stringupper

6.Using Google Geocoding and Street View Image APIs

  1. 6.1APIs to be used
  2. 6.2Create folders
  3. 6.3File goview.css
  4. 6.4Program geoweb.go
  5. 6.4.1User Form
  6. 6.4.2QueryEscape
  7. 6.4.3defer
  8. 6.4.4Using Google Geocoding and Street View Image APIs
  9. 6.4.4.1Required parameters

7.Go and MongoDB on MongoLab

  1. 7.1What’s NoSQL?
  2. 7.2What’s MongoDB?
  3. 7.2.1MongoDB Core Concepts
  4. 7.3MongoLab - The Fully-managed MongoDB-as-a-Service
  5. 7.3.1Sign Up
  6. 7.3.2Create a database subscription
  7. 7.3.3Database User
  8. 7.3.4mgo
  9. 7.3.5JSON Recap
  10. 7.3.6package mgo
  11. 7.3.6.1Function Close
  12. 7.3.6.2Function SetSafe
  13. 7.3.6.3Function Safe
  14. 7.3.6.4Function DB
  15. 7.3.6.5Function C
  16. 7.3.6.6Function Insert
  17. 7.3.6.7Function Find
  18. 7.3.6.8Function One
  19. 7.3.7package bson
  20. 7.3.7.1type M
  21. 7.3.8Program mongohqconnect.go
  22. 7.3.9Web app trails.go

8.Go and Gmail

9.A Fun, Weather Forecast Go Web App

  1. 9.1Register for an account at Forecast for Developers
  2. 9.1.1Study the API documentation
  3. 9.1.1.1The Forecast Call
  4. 9.1.1.2Data Points
  5. 9.1.2Our app weather.go
  6. 9.1.2.1Concurrent Queries
  7. 9.1.2.2Run the program
  8. Exercise

10.Deploying Go Web Apps to Heroku

  1. 10.1Cloud Computing Service Levels
  2. 10.1.1SaaS
  3. 10.1.2IaaS
  4. 10.1.3PaaS
  5. 10.2Create an account on Heroku
  6. 10.3Install the Heroku Toolbelt
  7. 10.4Prepare a web app
  8. 10.5Use Git
  9. 10.6Create a Procfile
  10. 10.7Install Godep
  11. 10.8Declare app dependencies
  12. 10.9Using godep with our project
  13. 10.10Add these new files to git
  14. 10.11Deploy the app
  15. Exercises
  16. 10.12Program gomongohq.go
  17. Exercise
  18. Exercise

11.Deploying Go Web Apps to Google App Engine

  1. 11.1Google App Engine
  2. 11.1.1Sandbox
  3. This is a Warning
  4. 11.1.2Services
  5. 11.1.3The Administration Console
  6. 11.1.4Applications (web and non-web)
  7. 11.1.5DataStore
  8. 11.2The Go runtime environment
  9. 11.3Download and Install the App Engine SDK
  10. Tip
  11. 11.4Let us build a small app (mytext.go) locally
  12. 11.4.1Program mytext.go
  13. 11.4.2Create the Configuration File
  14. 11.4.3Test the App
  15. 11.4.4Iterative Development
  16. 11.5Uploading Your App to Google’s App Engine
  17. 11.5.1Registering the App
  18. 11.5.2Upload and Access the app
  19. Access the app
  20. 11.6Web app upperstring.go
  21. Access the app
  22. 11.7Web app EXIF Map - blobstrex.go
  23. 11.7.1Program blobstrex.go
  24. 11.7.1.1File app.yaml
  25. 11.7.2Blobstore Go API
  26. Information
  27. 11.7.2.1The appengine package
  28. 11.7.2.1.1NewContext
  29. 11.7.2.2The blobstore package
  30. 11.7.2.2.1UploadUrl
  31. 11.7.3Uploading a photo (blob)
  32. 11.7.3.1Create an upload URL
  33. 11.7.3.2Create an upload form
  34. 11.7.4Using goexif
  35. 11.7.5Google Static Maps API
  36. 11.8Modifying geoweb.go for Google App Engine
  37. This is a Tip
  38. 11.9Check out

12.Web Toolkits and App Frameworks for Go

  1. 12.1Martini
  2. 12.2Installation of Martini
  3. 12.2.1Check whether Martini works
  4. 12.2.2Classic Martini
  5. 12.2.3Handlers
  6. 12.2.3.1Return Values
  7. 12.2.4Routing
  8. 12.2.5Serving Static Files
  9. 12.2.6Middleware Handlers
  10. 12.3Upload a Martini app to Google App Engine
  11. 12.4What next?

Contributors

About the Contributors

Mentoring at RubyLearning.org since 2008.

Sanat Gersappa

Occupation: Web Guy, Early Adopter, Alpha Geek, Options Trader. Skills: Specialist in Web technologies. Good at ASP.NET, Node.js, Go, Client-side Javascript frameworks.

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub