1
0
mirror of https://github.com/fumiama/terasu-cloudflared.git synced 2026-06-05 00:50:24 +08:00
Files
terasu-cloudflared/vendor/nhooyr.io/websocket/internal/xsync/go.go

26 lines
384 B
Go

package xsync
import (
"fmt"
)
// Go allows running a function in another goroutine
// and waiting for its error.
func Go(fn func() error) <-chan error {
errs := make(chan error, 1)
go func() {
defer func() {
r := recover()
if r != nil {
select {
case errs <- fmt.Errorf("panic in go fn: %v", r):
default:
}
}
}()
errs <- fn()
}()
return errs
}