Posts in "Golang"

Interesting development in the world of Go: in 1.26, the new() function will now accept expressions, not just types. This returns a pointer to the value, which will be useful for those types that use pointers for their fields:

type User struct {
   Age *int
}

user := User{}
var age int = 10
user.Age = new(age)

It also works for literal values, so that temporary age variable is strictly not necessary, although the linked post does state that it requires some consideration for types. Having user.Age = new(10) will work without issue as new will return a *int; but if Age were a *uint, you’ll get a type error.

I go on about unnecessary pointer types in the past (and will probably continue to do so in the future). To me, it’s just one of those paper-cuts you encounter in your day to day that you know can be made easier. So I consider this a welcome change. It’s not going to same me a ton on code, but every little bit helps.

Dear Go developers,

You don’t need to return pointers,
Unless you do need to return pointers.
But if you think you need to return pointers,
You probably don’t need to return pointers.

Instead, consider just returning regular struct values. Keep the nil-pointer panics at bay.

The exhaustive Go linter complaining about missing cases for switch statements with a default clause is killing me.

missing cases in switch of type this, and this, and this, and this, and…

Auto-generated description: A man in an office setting sits on a couch next to a bottle, with the text That's what the default is for.

Request for a go linter: something that would warn when an variable with the name err is not of type error:

func Bla() {
   err := 123    // 'err' not of type 'error'
}

Would’ve saved me a few hours today trying to test if a Future was not-nil, without actually waiting for the result.

Does Google ever regret naming Go “Go”? Such a common word to use as a proper noun. I know the language devs prefer not to use Golang, but there’s no denying that it’s easier to search for.

Broadtail

Date: 2021 – 2022 Status: Paused First project I’ll talk about is Broadtail. I think I talked about this one before, or at least I posted screenshot of it. I started work on this in 2021. The pandemic was still raging, and much of my downtime was watching YouTube videos. We were coming up to a federal election, and I was getting frustrated with seeing YouTube ads from political parties that offend me.