Go 1.26 interactive tour

88 points by makishimu


telemachus

Anton, if you're listening, thank you for this series and for new Accepted! series. (Go team, if you are listening, we need an equivalent of the Ruby Hero award. I nominate Anton.)

rau

Now, most crypto APIs will just ignore the random io.Reader parameter and always use the system random source (crypto/internal/sysrand.Read).

This seems like a poor decision to me. Replacing a function parameter with a global means that tests cannot run concurrently (note: ‘Because SetGlobalRandom affects the whole process, it cannot be used in parallel tests or tests with parallel ancestors.’).

I think that I understand the motivation, but this is just ugly. I could be wrong!

hobbified

It's crazy how often I've run into the lack of new(expr) over the years. Since Go 1.18+ you usually have the option of dancing around it with a helper like

func GimmePointer[T any](val T)*T {
    return &val
}

prior to that, I would often resort to something like &[]int{42}[0] in test code, where I needed it the most. I considered that too ugly for non-test code, though, and would write it out the long way — which is fine, but there are times when brevity harms readability, and times when brevity enhances readability, and this is the latter.

x := SomeBigStruct{
    // 10 lines
    Foo: new(int(42)),
    // another 10 lines
}

will be superior to

var fortyTwo int = 42
x := SomeBigStruct{
    // and then 10 lines later...
    Foo: fortyTwo,
    // etc.
}
zk

Passing thought: I wonder if runtime/secret is going to be useful for malware dev + evasion. Then there's this:

The runtime/secret package is mainly for developers who work on cryptographic libraries. Most apps should use higher-level libraries that use secret.Do behind the scenes.

So I'm wondering if this kinda feature has been possible for a while just not wrapped up in a nice way to do it?

oliverpool

Very well written.

Looking at https://go.dev/cl/722500, it reads:

append([]byte(nil), make([]byte, next)...)[:0]

Why not make([]byte, 0, next) ?