News for hackers. Stuff that matters.
Re:Goroutines: The concurrency model we wanted all along by chrsig on Friday July 07, 2023 @06:16PM (#36638994)
Generics!

    func streamingApply[T any](ch channel[T], fn func(T)){ 
         for {
            select {
            case <-ctx.Done():
            break
            case item, ok = <-ch:
                if !ok {
                    break
                }
                fn(item)
            }
        }
    }

For everyone that's complained about generics being introduced to go...It really does help clean up this type of repetition.

There are no comments on this comment yet.