jub0bs

jub0bs

@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!

2.4K followers276 following469 posts

Pinned

Perfloop, Tomás Senart's project, identified a subtle bug (due to an oversight about preflight on my part) in the CORS library I maintain for #golang. Pretty impressive! The latest release (v1.1.3) fixes the bug in question. github.com/jub0bs/cors/... perfloop.ai

perfloop.aiPerfloop · The Performance MachinePerfloop learns your system from code and telemetry, hunts a wide catalog of performance patterns, and delivers a stream of proven pull requests. Software that stays fast.

I love how the conjunction of #golang's modules system and build constraints lets you have your cake and eat it too! 🍰 You can let users of your library take advantage of the bleeding edge if they so wish without cutting off one of the currently supported Go toolchains.

When something tantalising gets merged at tip, you can put code that relies on it in a file guarded by a //go:build go1.27 build constraint and its pre-1.27 counterpart in a file guarded by a //go:build !go1.27 build constraint. No need to update your go.mod's go directive.

Unfortunately, this proposal would require a breaking change. Therefore, I've decided to retract it.

Paradoxically (perhaps), as the Go compiler becomes better at eliminating bounds checks, attacker-reachable panics due to incorrect programmer assumptions about indices become easier to find. #golang

#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.

🚀 "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

github.comspec: generic methods for Go · Issue #77273 · golang/goProposal: Generic Methods for Go A change of view. Background For clarity, in the following we use the term concrete method (or just method when the context is clear) to describe a non-interface me...

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).

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

An unfortunate bug snuck in v0.12.0: some middleware would disallow origins that they should have allowed. Fixed in v0.12.1. Apologies. 🙇

#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) } }

jub0bs reposted

Related #golang PSA: Gophers often mistakenly put a -u in 'go get -u foo', when they would have been better off with just 'go get foo'. 'go get foo' says to upgrade foo itself. It's shorthand for 'go get foo@upgrade' 'go get -u foo' says to *also* upgrade all the direct and indirect deps of foo.

Filippo Valsorda@filippo.abyssdomain.expert

PSA: go.sum is not a lockfile. You never need to look at go.sum. go.mod has everything you need.