How to use Buffalo, a Golang rapid web development Framework

Go Web Framework

Intro – Rapid Software Development in the Modern World with Golang

(Feel free to skip to the tutorial)

This post is the first in a planned series about rapid software development in the modern world.

Elad was talking to me about how non-trivial it has become to choose a stack in today’s world. And let’s say you’ve chosen your tools – only the most experienced developers know how to set up CI, testing, deployment, instrumentation, monitoring, security, etc. correctly. A lot of Ops knowledge is involved in even getting things initially running.

We’ve been dealing a lot with rapid developer onboarding at Otomato software. But what got us started diving deeper into this – was my conversation with Elad Meidar a few months back.

Our current goal is to take that knowledge we’ve accumulated and make it available as a service. And while we’re doing that – we’re exploring the currently available tooling.

Enter Buffalo

Buffalo is a framework (or a tool) for rapid web development in Go. Cloud Native DevOps folks (and that’s what we are at Otomato) have a soft spot for Golang, so I’m starting this series with Buffalo.

The official getting started section of Buffalo documentation is excellent but as I ran through it, I noticed it lacks some operational details that I’m planning on exposing. Again there’s Ops knowledge lurking in the dark!

Installations

Reasonably naturally, one would need to install Golang.
On a Mac:

brew install golang

On Ubuntu/Debian:

sudo apt update && sudo apt install golang

Note: on older systems (such as Ubuntu 20.04) you’ll get a very old version of Go (1.13) by default when installing with apt. So instead – choose the download-n-extract option here.

For additional installation options, go here

Do you do frontend?

Buffalo can generate both pure backend API services and fully-fledged web apps with frontend matter included. The frontend is in Javascript – so if you want that – you’ll also need Node and either yarn or npm (the default).
On a Mac:

brew install nodejs

On Ubuntu/Debian:

sudo apt update
sudo apt install nodejs npm

Do you want containers?

Buffalo makes quite a few educated assumptions when generating your project. One of them is that you’ll want to wrap your app in a container. You can, of course, opt-out, but why? So if you’re going with the flow and enjoying the benefits of containerization – you probably already have Docker installed. If not – please do so now – we’ll need it further along the tutorial.

Finally – bring in the Buffalo Web Framework for Golang

On a Mac:

brew install gobuffalo/tap/buffalo

On Linux;

wget https://github.com/gobuffalo/cli/releases/download/v0.18.8/buffalo_0.18.8_Linux_x86_64.tar.gz
tar -xvzf buffalo_0.18.8_Linux_x86_64.tar.gz
sudo mv buffalo /usr/local/bin/buffalo

Create a Buffalo Golang project

Buffalo has a project scaffolding feature that allows us to generate a new app complete with:

  • a local git repository
  • a backend api
  • a db integration
  • a frontend
  • a Dockerfile
  • a CI pipeline.

There is no ads to display, Please add some