Go Icon


Go is a programming language built to resemble a simplified version of the C programming language.
330 Stories
All Topics

Raul Jordan rauljordan.com

This is why Go’s error handling is awesome

// In controllers/user.go
if err := database.CreateUser(); err != nil {
    log.Errorf("Could not create user: %v", err)

// In database/user.go
func CreateUser() error {
    if err := db.SQLQuery(userExistsQuery); err != nil {
        return fmt.Errorf("could not check if user already exists in db: %v", err)

// In database/sql.go
func SQLQuery() error {
    if err := sql.Connected(); err != nil {
        return fmt.Errorf("could not establish db connection: %v", err)

// in sql/sql.go
func Connected() error {
    if noInternet {
        return errors.New("no internet connection")

The beauty of the code above is that each of these errors are completely namespaced by their respective function, are informative, and only handle responsibility for what they are aware of. This sort of error chaining using fmt.Errorf("something went wrong: %v", err) makes it trivial to build awesome error messages that can tell you exactly what went wrong based on how you defined it.

Patrick DeVivo github.com

Using SQL to query git repos

gitqlite is a tool for running SQL queries on git repositories. It implements SQLite virtual tables and uses go-git. It’s meant for ad-hoc querying of git repositories on disk through a common interface (SQL), as an alternative to patching together various shell commands.

Mine your repo’s history for goodies. Here’s how to get commit count by author email:

SELECT author_email, count(*) FROM commits GROUP BY author_email ORDER BY count(*) DESC

Jon Bodner capitalone.com

Go is boring...and that’s fantastic!

Jon Bodner shared a deep dive into why the world depends on simple, reliable, well-understood technologies like Go.

The one exciting thing that Go has is built-in concurrency support via goroutines, channels, and select. However, it is based on ideas from CSP, communicating sequential processes, which was first described in 1978.

This doesn’t sound like a programming language from the 21st century, does it?

And yet, Go is the 3rd most wanted and (maybe not coincidentally) the 3rd highest paying language, according to Stack Overflow. Every startup in Silicon Valley is using Go to build their infrastructure. Docker, Kubernetes, etcd, Terraform, Vault, Consul, Traefik and lots of other cutting-edge projects are written in Go. So what’s going on? Why is everyone interested in this boring language?

As a fun aside, I searched the Go Time transcripts for the word “boring” and found this gem from Kelsey Hightower on Go Time #114

When infrastructure gets boring, something else will become exciting above it.

…which makes sense why Go being boring is fantastic, because there’s so many exciting things being built with it.

Go Time Go Time #135

We have regrets

Leaning from mistakes is key to progressing. In this episode Ben, Aaron, Kris, and Jon discuss some of our mistakes - like spending too much time designing a feature that isn’t that important, or using channels excessively when first learning Go - and how we learned from them.

Kubernetes github.com

Kubernetes multi-cluster deployment automation service

Application deployment and management should be automated, auditable, and easy to understand and that’s what beetle tries to achieve in a simple manner. Beetle automates the deployment and rollback of your applications in a multi-cluster, multi-namespaces kubernetes environments. Easy to integrate with through API endpoints & webhooks to fit a variety of workflows.

Kubernetes multi-cluster deployment automation service

Go github.com

Go+ is like Go if it were built for data scientists

This new data-science-focused language is fully compatible with Go*, but streamlines things for data science use. It simplifies common scripting tasks. This in Go:

package main

func main() {
    a := []float64{1, 2, 3.4}

Becomes this in Go+:

a := [1, 2, 3.4]

And adds features like list comprehensions for easier data processing:

a := [1, 3, 5, 7, 11]
b := [x*x for x <- a, x > 3]
println(b) // output: [25 49 121]

mapData := {"Hi": 1, "Hello": 2, "Go+": 3}
reversedMap := {v: k for k, v <- mapData}
println(reversedMap) // output: map[1:Hi 2:Hello 3:Go+]

It can be compiled directly to bytecode or transpiled into Go code. Give it a go on the playground.

*I almost described it as a “superset” of Go, but I’m not 💯 if that’s true.

Go github.com

Rob Pike's toy Lisp interpreter in Go

This program was a joy to put together. Its purpose was fun and education, and in no way to create a modern or even realistic Lisp implementation. The goal was to turn that marvelous page 13 into a working interpreter using clean, direct Go code.

If you’re interested in what one of Go’s creators believes is “clean, direct Go code”, then you’re interested in this repo.

Ian Lance Taylor blog.golang.org

The next step for Go generics

Ian Lance Taylor:

It’s been almost a year since we last wrote about the possibility of adding generics to Go. It’s time for an update.

Jump straight to the updated design draft or read Ian’s post for details on the new experimental translation tool and the the kinds of feedback they are seeking. If you’re only interested in a release date for the final implementation:

if everybody is completely happy with the design draft and it does not require any further adjustments, the earliest that generics could be added to Go would be the Go 1.17 release, scheduled for August 2021.

Note: that’s the earliest it will be. This is not a guarantee by any means.

Go github.com

A lightweight, high-speed immutable database for systems and applications

With immudb you can track changes in sensitive data in your transactional databases and then record those changes permanently in a tamperproof immudb database. This allows you to keep an indelible history of sensitive data, for example debit/credit card transactions.

There are so many options for storing data these days. If you haven’t heard Go Time’s excellent episode on databases yet, Jaana does a great job of explaining some of the trade-offs.

Go Time Go Time #132

The trouble with databases

Databases are tricky, especially at scale. In this episode Mat, Jaana, and Jon discuss different types of databases, the pros and cons of each, along with the many ways developers can have issues with databases. They also explore questions like, “Why are serial IDs problematic?” and “What alternatives are there if we aren’t using serial IDs?” while at it.

Go github.com

Learn Go with this huge repository of examples, exercises, and quizzes

This repository contains the examples, exercises, and quizzes for my Go course: Learn Go Programming: Complete Bootcamp Course. However, even without the course, using this repository, you can learn a great deal of information about Go. Inside, there are thousands of examples, exercises and quizzes.

You’re welcome to contribute your own exercises, quizzes and wiki.

Christian Scott christianfscott.com

Making Rust as fast as Go (fake news)

Is this more proof of Cunningham’s law, which says, “The best way to get the right answer on the Internet is not to ask a question; it’s to post the wrong answer.”

Update: as some keen HN commenters have pointed out, it looks like the rust program is not actually equivalent to the go program. The go program parses the string once, while the rust program parses it repeatedly inside every loop. It’s quite late in Sydney as I write this so I’m not up for a fix right now, but this post is probably Fake News.

Read Christian’s post then have fun in the comments and discussions on HN and Reddit analyzing his hypothesis, which includes a repo of code to backup his ideas.

Go caddyserver.com

Caddy 2 is production-ready

Caddy has been around for a while, so this is a major release for the project. Hard to believe this is true today (emphasis added)

Still the only web server to use TLS automatically and by default.

Caddy 2’s new architecture was inspired by 5 years of experience with Caddy 1 and took 14 months to design. There’s a lot here, so we probably need to get the team on The Changelog or Go Time to discuss in depth.

Go Time Go Time #128

Immediate mode GUIs

Mat, Johnny and Jon are joined by Elias, creator of Gio, to discuss GUIs. Specifically, we explore the pros and cons of immediate vs retained mode and explore some examples of each, as well how some frameworks like React are attempting to bring the benefits of immediate mode to a retained mode world (the DOM).

Todd Kulesza blog.golang.org

Go developer survey 2019 results

Good news! For 2019 there were 10,975 responses to the survey — that’s almost twice as many as last year. Here are few major findings from the results, but of course, you should dig in because they make it really easy to scan and grok the details.

  • The demographics of our respondents are similar to Stack Overflow’s survey respondents, which increases our confidence that these results are representative of the larger Go developer audience.
  • A majority of respondents use Go every day, and this number has been trending up each year.
  • Respondents are using Go to solve similar problems, particularly building API/RPC services and CLIs, regardless of the size of organization they work at.
  • Most teams try to update to the latest Go release quickly; when third-party providers are late to support the current Go release, this creates an adoption blocker for developers.
  • Almost everyone in the Go ecosystem is now using modules, but some confusion around package management remains.
  • VS Code and GoLand have continued to see increased use; they’re now preferred by 3 out of 4 respondents.
0:00 / 0:00