Preface

I started writing Ruby in 2010. For eight years, it was my go-to language — the one I reached for when I needed to think through a problem, build a prototype, or ship a feature. Ruby’s slogan is “A Programmer’s Best Friend,” and I believe it.

In 2018, I took a job that used Go. I had never written a line of it. Eight years and many Go releases later, I still write it every day — and the Ruby-to-Go mappings I discovered as a newbie remain the fastest way to onboard Rubyists onto my team.

The first thing I did was try to relate everything back to Ruby. How do I define a class? (You don’t — you use a struct.) How do I handle exceptions? (You don’t — you check errors as return values.) How do I iterate over an array? (With for, not each.) Every answer was a small revelation about how Go thinks differently.

I documented what I learned. Those notes became articles. The articles became this book — first published in 2019, now updated for Go 1.22+. It reached the top 10 on Amazon and peaked at #3. That proved something to me: relating a new language to the one you know by heart isn’t just a learning trick — it’s the fastest way to teach. Every Ruby-to-X book I’ve written since follows the pattern established here.

This book teaches Go by mapping every concept back to Ruby. If you know how instance variables work in Ruby, you’ll learn how structs work in Go. If you know require, you’ll learn import. If you know begin/rescue, you’ll learn if err != nil. No abstract explanations — just the Ruby you know, translated to the Go you want to learn.

Go is a great language. It compiles to a single binary. It’s statically typed and garbage-collected. It powers Docker, Kubernetes, and Terraform. Companies like Google, Netflix, and Uber run it in production at scale. It’s fast, simple, and built for the kind of backend systems work that defines modern software engineering.

But more importantly: Go will make you a better programmer. Learning to think in types, to handle errors explicitly, to compose instead of inherit — these patterns will change how you write code in any language, including Ruby.

This book doesn’t ask you to take notes or memorize syntax. Just read, type the examples, and let your Ruby knowledge do the heavy lifting.

Ruby is still my favorite scripting language. I use it every day. This book is not about leaving Ruby behind — it’s about adding Go to your toolkit.

Let’s get started.