"Open-source but closed for contributions" is the sweet spot for me. I like @honnef.co's take on this approach: github.com/dominikh/go-...
@jub0bs.com
infosec enthusiast • Go dev & trainer • contributor to the Go project • minimalist • chaotic good • trying to make sense of the Web • he/him Blog: https://jub0bs.com Free Go course: https://github.com/jub0bs/go-course-beginner Free 🇵🇸! Leave 🇱🇧 alone!
"Open-source but closed for contributions" is the sweet spot for me. I like @honnef.co's take on this approach: github.com/dominikh/go-...
I've just filed a proposal to make bool an ordered type (compatible with operators <, <=, >, and >=) in #golang: github.com/golang/go/is...
Fascinating! Thanks for sharing. 🙇
#golang quiz: What happens if you try to compile and run the following program?
package main
import (
"fmt"
"math"
)
func main() {
fmt.Println(int(math.NaN()))
}
a. It prints 0.
b. It prints -1.
c. It panics.
d. Compilation fails.
e. Something else.
Besides, I welcomed support for ranging over ints. The gain in readability over a classic three-clause loop is real, as explained in the following comment: github.com/golang/go/is...
One source of complexity surrounding iterators, IMO, is when the iterator is designed as "impure", in the sense that even if the yield function you pass it is a pure function, consuming the iterator has side effects. A subtlety that can trip even seasoned Gophers up: github.com/golang/go/is...
Ranging over a channel too only yields (at most) a single value.
As a consumer of iterators, you're largely isolated from the complexity they deploy under the hood, esp. if those iterators are designed as pure functions. Things are different if you have to implement iterators yourself but, again, not prohibitively so, IMO.
Thanks! Yeah, and the kind of forward compatibility that error types unlocks in comparison to error values is appreciable as well.
Well, generics certainly made the language more complex, but not prohibitively so, IMO. I think Go's agenda of simplicity is as strong as ever.
A bit of a downer, this one, lads! 😅
At some stage of this episode, Kris wishes for some (official) guidance about error handling. The following take is far from official and comprehensive, but I'd love to hear your thoughts about it: jub0bs.com/posts/2025-0...
I think we all do! The proposal being accepted so early in this release cycle gives me high hopes for Go 1.27. 🤞
Since the inception of generics in Go (1.18), methods could not introduce type parameters. You had to resort to declaring package-scoped functions instead; code organisation and ergonomics typically suffered.
The proposal lifts this restriction for concrete types (though not for interface types).
🚀 "spec: generic methods for Go" has been accepted!
You will soon (1.27?) be able to declare (on concrete types only) methods that introduce type parameters, i.e. type parameters other than the ones (if any) that come from the method's receiver.
github.com/golang/go/is...
#golang
Thanks. 😊
Not a big fan of that new Go method in general, but you're right that it helps readability in this case: go.dev/play/p/HuIoL...
(If you get a timeout on the playground, try again, or try running the program locally.)
A friendly reminder that a Go program doesn't need an import of the "unsafe" package to undermine the language's type system; a synchronisation bug may be enough: go.dev/play/p/L0_Zr...
#golang
Great idea! I wasn't planning to, but now I have to explore it to live up to your expectations. 😅
For months (maybe years, even) now, I've been accumulating notes with a view to producing a performance-oriented Go training course. There's just so many techniques and tools to master! I'm hopeful for a release some time in 2026, though. 🤞 #golang
If you've already migrated to Go 1.26, there's no longer any point in relying on github.com/jub0bs/errutil. Simply rely on errors.Astype instead.
pkg.go.dev/errors#AsType
#golang
Do tell... 🍿
An unfortunate bug snuck in v0.12.0: some middleware would disallow origins that they should have allowed. Fixed in v0.12.1. Apologies. 🙇
🙈
"If you think you need this, you're almost certainly wrong."
🎉 I've just released v0.12.0 of jub0bs/cors, my CORS middleware library for #golang!
- Go 1.25 or above is now required.
- Some minor performance improvements.
Still guaranteed free of AI slop, of course.
github.com/jub0bs/cors
$ go install golang.org/dl/go1.26.0@latest $ go1.26.0 download Downloaded 0.0% ( 0 / 63102509 bytes) ... Downloaded 50.0% (31551254 / 63102509 bytes) ... Downloaded 100.0% (63102509 / 63102509 bytes) Unpacking go1.26.0.openbsd-arm64.tar.gz ... Success. You may now run 'go1.26.0' $ go1.26.0 version go version go1.26.0 openbsd/arm64
🎆 Go 1.26.0 is released!
🗒️ Release notes: https://go.dev/doc/go1.26
⬇️ Download: https://go.dev/dl/#go1.26.0
#golang
💯
#golang quizz: why is the implementation of the following function naive/incorrect, and how would you fix it? 😉
// opposite returns the opposite of comparator function cmp.
func opposite[T any](cmp func(T, T) int) func(T, T) int {
return func(x, y T) int { return -cmp(x, y) }
}
I must confess I regret github.com/golang/go/is.... I've since found cmp.Or to be quite useful, esp. for implementing comparator functions for struct types. Thanks to @carlana.net for pushing for its addition to #golang's standard library.
Well, I might produce a v0.12.0 to accompany Go 1.26, whose release is imminent.