表示 HN: Gopherawaitof: For Dwell up for of Library for Golang
Provides a generic function ForAwaitOf[T any](tasks []func() T, handler func(t T)) that mimics the behavior of the for await..of construct in JavaScript. Here’s an example. package main import ( “fmt” “time” “github.com/gopherawaitof/gopherawaitof” ) func main() { start := time.Now() tasks := []func() string{ func() string { time.Sleep(time.Second * 3) return fmt.Sprintf(“task 1 finished at t=%f”,…