golang function defer

This is an interesting way to do defer in golang.


for i, v := range values {
    go func(i int, v string) {
        defer func() { done <- true }() // Always signal completion
        if i == 1 {
            return
        }
        fmt.Println(v)
    }(i, v)
}









Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20