The Applied Go Weekly Newsletter logo

The Applied Go Weekly Newsletter

Subscribe
Archives
March 3, 2024

Of cod fish and gophers • The Applied Go Weekly Newsletter 2024-03-03

AppliedGoNewsletterHeader640.png

Your weekly source of Go news, tips, and projects

JuiceFS, Bacalhau,... I stumbled over quite a few applications Written In Go™ lately. It's amazing to see what cool things people make possible with Go. But it's absolutely jaw-dropping to see how someone uses Go to hold a disease at bay.

👇 More below! 👇

ʕ◔ϖ◔ʔ

Of cod fish and gophers

Computer too small? Send your computing jobs elsewhere. Data in the cloud on other people's computers? Send your data processing job to the data.

Sounds trivial, but distributed computing usually requires some orchestration. The problem: Typical software orchestration systems are overkill if you only need to dispatch some data processing jobs and collect the results.

I tested Bacalhau, a compute job distribution system that has been tailored for sending batch jobs to remote nodes, where they can process data or make use of extra hardware (GPUs). Bacalhau's design is all about ease of use.

Bacalhau can distribute containers and WASM binaries. The examples in Bacalhau's documentation do not (yet) cover Go+WASM, hence I decided to create my own.

Distributed computing with dried, salted cod fish, WASM, and (Tiny)Go · Applied Go

Matt Boyle is Go-powered, apparently

How Matt Boyle creatively applied his software development expertise to build a comprehensive system for monitoring and managing his diabetes. Applied observability at its best.

Keeping myself alive with Go - GopherCon SG 2023 - YouTube

A Gentle Introduction to Unit Testing in Go

Learn the basics of unit testing on a sample project. Because hands-on learning is most effective. – By Lanre Adelowo

A Gentle Introduction to Unit Testing in Go | Better Stack Community

How a Distributed File System in Go Reduced Memory Usage by 90%

An overview of the techniques that JuiceFS uses for reducing metadata memory consumption by 90%. (JuiceFS is written in Go.)

How a Distributed File System in Go Reduced Memory Usage by 90% - JuiceFS Blog

Special announcement: Learn Go debugging with Matt

If your code breaks unexpectedly, take a break and learn the secrets of effective Go debugging.

Matt Boyle created a new course, The Ultimate Guide to Debugging With Go, and as an Applied Go Weekly Newsletter reader, you can get 40% off of the course price through this link or by using the coupon code APPLIEDGO40 until Sunday, March 10th. (This is not an affiliate link. I get no commission or any bonus for sharing Matt's course here. But I think that many of my readers would appreciate getting their hands on a solid training on troubleshooting broken code. Troubleshooting is always a good skill to have.)

Podcast corner

Cup o' Go

If you peek into the Projects section, you'll understand why "gleefully" is a pun. Or just listen to this episode.

Cup o' Go | Gleefully announcing new releases and projects from around the 🌌 GopherVerse & GopherJS interview with Grant Nelson

Go Time

So you think Go is a backend language? Nonononononono. Go is an artist's language!

Creating art & visualizations with Go featuring Anthony Starks (Go Time #305)

go podcast()

How could he! ;-)

go podcast() | 029: I've a confession to make, I've wrote 2 apps in Django

Backend Banter

Teej DeVries runs a course on Boot.dev about memory management. In this episode, he talks to host Lane Wagner about memory management in different languages, like Go, C, OCaml, and Rust.

Backend Banter | #042 - Rust is the WORST language to learn first ft. Teej DeVries

Go tip of the week: JSON Lines

How do you save tabular data?

CSV comes to mind, but CSV can be too simplistic for the data to be saved. And CSV can have different column separators and different methods for character escaping. Too confusing. Thanks, but no thanks.

A JSON array to the rescue? Maybe, but why spreading each row across multiple lines? (If proper JSON formatting is applied.)

Recently, I stumbled across a data format that looks as if CSV and JSON had a child:

JSON Lines.

JSON Lines, or JSONL, is a line-oriented format. It is not JSON, but each line is valid JSON. This is a clever idea. A JSONL file can be processed line by line. Unix CLI tools love this! Imagine running grep, awk, wc or other Unix-ish tools on your "JSON" data. And each line can contain data that is more complex than a line of CSV, with much less ambiguity.

Bonus: encoding/json's Encoder is able to write JSON lines out of the box. Every call to Encode() generates a single line of JSON with a newline at the end.

type line struct {
    A string
    B int
}

func main() {
    e := json.NewEncoder(os.Stdout)
    e.Encode([]line{
        {"Area", 51},
        {"Route", 66},
    })
    e.Encode([]line{
        {"Heaven", 17},
        {"Catch", 22},
    })
}

Output:

[{"A":"Area","B":51},{"A":"Route","B":66}]
[{"A":"Heaven","B":17},{"A":"Catch","B":22}]

(Playground)

There you have it: readable, CLI-tool-friendly tabular data with some "extra structure" in each column.

Overheard on LinkedIn

Many software engineering teams don't have time to do it right.

But surprisingly, they have time to do it twice.

– Daniel Moka

More articles, videos, talks

Adding Color to Terminal Output in Go

Adding colors to terminal output is easier than you might think. Stephanie You explains how to include escape codes in your output, no package required.

Building REST APIs in Go 1.22 - New Features - YouTube

Elliott Forbes demonstrates the new net/http routing features.

JetStream KV: A fascinating alternative to Redis... - YouTube

Jeremy Saenz about NATS' built-in distributed persistence layer JetStream versus Redis.

How To Build AWS-Compatible APIs: AWS Sigv4

Sigv4 is a content signature that clients must use for sending requests to (many) AWS APIs. Dan Goodman shows how to create middleware that accepts Sigv4 requests.

Projects

Libraries

GitHub - chris-tomich/adtenum: A Rust style enums implementation for Go.

Enums in Go suck (says the author of this article), but with this package, they suck less.

GitHub - go-pkgz/routegroup: Lightweight library for route grouping and middleware integration with the standard http.ServeMux

routegroup allows grouping routes under a common path prefix or middleware stack, including nested groups.

GitHub - adelowo/gulter: Golang middleware for handling multipart/form-data and uploading files

Easy uploading of files to your web app. The name is derived from Node.js's multer.

GitHub - JustinTimperio/gpq: GPQ is a high performance embeddable double priority queue with complex priority ordering guarantees

If your critical workloads require complex queuing and delivery order guarantees, this faster-than-fibonacci-heaps priority queue comes handy.

GitHub - matt1484/chimera: Chi-based Module for Easy REST APIs (like FastAPI but for go)

Let chimera do the mundane API tasks for you: parsing of form requests, serializing of responses, OpenAPI docs from structs, and more.

GitHub - gomoni/it: iterator library for go using a rangefunc experiment

A package to make using the experimental range over function feature more convenient.

GitHub - ortuman/nuke: ⚡ A memory arena implementation for Go.

Memory arenas were an experiment in Go 1.20 but are now on hold indefinitely due to serious API concerns. Anyone who needs to get the last bit of performance out of their Go app might want to have a look at Nuke.

GitHub - zpatrick/cfg: Consolidate and validate application configuration.

Multi-source configuration handling. (Flags, environment variables, INI files, and TOML files.)

Bulma-Gomponents | Bulma-Gomponents

This is for fans of both the Gomponents package and the Bulma CSS framework.

Tools and applications

GitHub - EchoVault/EchoVault: Distributed in-memory data store with an emphasis on speed and reliability.

The project aims at delivering Redis-like data structures and commands. Writes are strongly consistent but can be changed to eventually consistent, with last-write-wins semantics.

GitHub - HexmosTech/glee: Dev-friendly Blogging Setup

Glee manages the blogging process for your Ghost blog. The authors recently ported the tool from Python to Go.

GitHub - Data-Corruption/Go-Release-Builder: Go project template for automatically creating release zips with GitHub Actions, targeting Linux and WSL environments.

Author: "I don't know how versioning releases works, so i built my own system ". Fair enough.

GitHub - 0b1-k/DFPlayerMini: Go / TinyGo driver for the DFRobot DFPlayer Mini MP3 chip

Because manually skipping a song is so 2007.

GitHub - akhuntsaria/h2c: HTTP/2 over cleartext server in Go

"It's unoptimized, partial, but if you prefer reading amateur Go code to reading RFCs - it'll be perfect."

GitHub - sonalys/fake: A Type Safe Go mocking library

Create type-safe mocks for any public interface.

Completely unrelated to Go

Don't talk about the problem only, talk about the impact.

"Help, I see a problem and no one is prioritizing it!" | nicole@web

Happy coding! ʕ◔ϖ◔ʔ

Questions or feedback? Drop me a line. I'd love to hear from you.

Best from Munich, Christoph

Not a subscriber yet?

If you read this newsletter issue online, or if someone forwarded the newsletter to you, subscribe for regular updates to get every new issue earlier than the online version, and more reliable than an occasional forwarding. 

Find the subscription form at the end of this page.

How I can help

If you're looking for more useful content around Go, here are some ways I can help you become a better Gopher (or a Gopher at all):

On AppliedGo.net, I blog about Go projects, algorithms and data structures in Go, and other fun stuff.

Or visit the AppliedGo.com blog and learn about language specifics, Go updates, and programming-related stuff. 

My AppliedGo YouTube channel hosts quick tip and crash course videos that help you get more productive and creative with Go.

Enroll in my Go course for developers that stands out for its intense use of animated graphics for explaining abstract concepts in an intuitive way. Numerous short and concise lectures allow you to schedule your learning flow as you like.

Check it out.


Christoph Berger IT Products and Services
Dachauer Straße 29
Bergkirchen
Germany

Don't miss what's next. Subscribe to The Applied Go Weekly Newsletter:
LinkedIn
This email brought to you by Buttondown, the easiest way to start and grow your newsletter.