Go Icon

Go

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

Peter Ohler github.com

A journey building a fast JSON parser and full JSONPath (Oj for Go)

Peter Ohler:

I had a dream. I’d write a fast JSON parser, generic data, and a JSONPath implementation and it would be beautiful, well organized, and something to be admired. Well, reality kicked in and laughed at those dreams.

This post lays out Peter’s plan, his journey, and his lessons learned in great details. Seems like it’d pair nicely with the recent Go Time all about JSON.

Go Time Go Time #140

The latest on Generics

Robert and Ian join us to talk about the latest updates on generics in Go. What type of feedback are they looking for as developers get their hands on tools designed to experiment with generics and Go? What was the deal with the featherweight Go paper that also discussed generics? Why can’t we use angle brackets for generics?

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}
    println(a)
}

Becomes this in Go+:

a := [1, 2, 3.4]
println(a)

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.

0:00 / 0:00