19 lines
295 B
Go
19 lines
295 B
Go
|
package utils
|
||
|
|
||
|
func WaitFor(fn func()) <-chan struct{} {
|
||
|
ch := make(chan struct{})
|
||
|
go func() {
|
||
|
defer close(ch)
|
||
|
fn()
|
||
|
}()
|
||
|
return ch
|
||
|
}
|
||
|
|
||
|
func ToLookupMap[T comparable](s []T) map[T]struct{} {
|
||
|
m := make(map[T]struct{}, len(s))
|
||
|
for _, item := range s {
|
||
|
m[item] = struct{}{}
|
||
|
}
|
||
|
return m
|
||
|
}
|