DEV Community

Cover image for DevLorem: Rewritten from the ground up in Go
Kevin Woblick
Kevin Woblick

Posted on • Originally published at blog.kovah.de

3

DevLorem: Rewritten from the ground up in Go

About 3 weeks ago my good old DevLorem project was a simple PHP website that generated Lorem Ipsum text made from movie quotes of famous actors and actresses. I decided to rewrite the whole thing with Go to dive into the language and its features.

Yesterday I released version 2, the complete rewrite with many more features. A demo of the website and API is available on devlorem.kovah.de.

Using Go to develop a feature-rich application

The main idea was to have one single binary that could be used as a web server handling the website, as well as a CLI tool to generate quotes right in the terminal. The first steps of getting a simple website up and running with Go were fairly straight forward. I used the gorilla/mux package, which provides a set of tools to run a HTTP web server. The examples have given me a good direction to build both the website itself, and the API.

Adding CLI commands were a bigger task as I also had to implement the generation in the terminal. The Cobra package, also used by famous projects like Hugo, has given me the perfect framework to build all command line options.

One binary for 7 platforms, and a Docker image

One of the most important features after the rewrite: DevLorem is now available as a single binary for 7 different platforms, including Linux, macOS and Windows. With the help of the go.rice package, I was able to bundle all assets, from the quote sources to the static CSS and JavaScript for the website, into one binary.

Besides of that, I built a Docker image that is now available as kovah/devlorem on the Docker Hub. It provides all features of the tool itself.

You can download the executables from the latest release.

The first steps with Go

Go itself is an amazing language. After writing the dynamically typed PHP and Python, using a strict type system was a great step forward. I already worked with static types in Rust, which was more a pain than a help because I spent more time fighting with type abstractions than writing productive code. Go has a clear and easy to understand type system and I was able to work with it right from the start. If you want to learn Go and come from another programming language, your best way to start is the Go by Example website. It has all the important aspects of Go packed into simple examples.

I will probably use Go more in the feature, and update the CorporateLorem tool too.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay