samber / mo

🦄 Monads and popular FP abstractions, powered by Go 1.18+ Generics (Option, Result, Either...)
https://pkg.go.dev/github.com/samber/mo
MIT License
2.47k stars 80 forks source link

Is there a good way to define a Future of nothing? #26

Closed serbrech closed 10 months ago

serbrech commented 1 year ago

Hi, this might be a noob question.

When doing an async computation, there are cases where we don't have a resolve value, but we might have an error. Future requires to define a resolve type, since there is no non-generic definition.

Is that an unusual case for Future usage? Is there another construct that I should use?

yougahu commented 1 year ago

struct{} means nothing in golang. For example you can use map[T]struct{} as a set.

samber commented 10 months ago

I agree, this is the best way to do it.