Comment

Comment by dumbo-octopus

One could theoretically pull out the shared boilerplate to a utility function like:

    func runTask[T any](task func() (T, error)) chan result[T] {
        ch := make(chan result[T])
        go func() {
            defer close(ch)
            res, err := task()
            ch <- result[T]{ el:res, err:err } }()
        return ch }
Does that sort of thing happen much in practice?

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton