Go web application example project

Avatar of the author Willem Schots
13 Mar, 2024
~4 min.
RSS

You know the saying “a good example is worth a thousand blog posts”?

Well probably not, because I just made it up. But the point stands, source code can provide a great way to learn.

I remember when I started out in Go, that I looked for example repositories. I don’t think I ever found any.

Most public repositories fall into two categories:

  • Kubernetes, Docker or similar giant open source projects.
  • “Quick start” repositories that provide scaffolding for getting a project of the ground.

While both are interesting, this is usually not what you’re looking for. You want something similar to what you’re building.

Often this something is a kind of “business” web application. The kind of projects that you might build in NestJS, Laravel, Django or Ruby on Rails if you’re using a different language.

Incentives

Now the issue is, the large majority of these kind of Go web applications are locked away in private repositories.

Building and maintaining a web application costs time, money and effort. The companies that own these repositories have no incentive to share their source code.

Which brings me to my incentive: I’m working on a (paid) guide about building Go web apps.

Having well-structured and documented source code makes it a lot easier to write this guide. I’ll be able to refer to a real code base and won’t need to make up examples.

Let’s build an example app

So here’s what I’m going to do:

  1. Build an open source web application in Go.
  2. Host and maintain this web application.
  3. Live tweet the development on Twitter/X.
  4. Use the source code and other learnings in the guide.

It will be fun. I hope.

The domain

My plan is to build a web application for real estate agents (“Agent”) and people searching for properties (“House Hunters”).

Why? Well, it’s a domain that most people are somewhat familiar with and it includes enough substance to give the project some depth.

MVP

  • House Hunters can browse listings in a list view/individual view.
  • House Hunters can filter listings.
  • House Hunters can respond to listings.
  • Agent can authenticate by password.
  • Agent can invite the rest of their team.
  • Agent can browse listings.
  • Agent can publish/unpublish/edit/delete listings.
  • Agent can view responses to a listing.
  • Agent gets a notification of new responses via email.

A listing will consist of:

  • Title.
  • Description.
  • Images+Captions.
  • For Rent (Monthly price) / For Sale (Total price).
  • Best effort list of technical properties (square footage, nr. of rooms etc.)

Below you’ll find some sketches of the UI I have in mind:

Listings overview sketch.
Single listing sketch.
Admin panel sketch.

Further plans

  • House Hunters can browse listings on a map.
  • Agent can schedule when listings are published/unpublished.
  • House Hunters can save searches and be notified of new listings that match their search.

The techical side

The main focus of this project will be on the Go backend code. I will use the standard library as much as possible and minimize the use of third-party code.

On the frontend, the HTML will be rendered server side and enriched with Javascript where necessary.

I'm no Javascript expert, but I'll do my best. Feel free to jump in with pull requests if you think anything can be improved.

For styling the project I will use Tailwind, it will allow me to move quickly and spend more time focussing on the Go code.

Some other notes:

  • Will be deployed to a cheap cloud server at Hetzner.
  • Storage will be done in PostgreSQL or SQLite.
  • Images for listings will be stored on disk.
  • Cookie based sessions.
  • Password authentication.
  • Unit testing and integration testing included.
  • JSON API included.

Repository and live url

The repository is called willemschots/househunt and can be found here, the live web app is available at examplego.com.

Participate

If you have suggestions or comments:

  • Help out by creating issues or pull requests.
  • Follow along on Twitter/X where I’m live tweeting the development.
  • Email me directly here.

Stickers

I’ve also ordered some cool stickers that I will send to people that contribute, but it will take a while for them to be printed and shipped.

For now the proof will have to do:

Stickers proof document
The proof send by the sticker company.

Get my free newsletter every second week

Used by 500+ developers to boost their Go skills.

"I'll share tips, interesting links and new content. You'll also get a brief guide to time for developers for free."

Avatar of the author
Willem Schots

Hello! I'm the Willem behind willem.dev

I created this website to help new Go developers, I hope it brings you some value! :)

You can follow me on Twitter/X, LinkedIn or Mastodon.

Thanks for reading!