mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-28 14:09:58 +00:00
TUN-7125: Add management streaming logs WebSocket protocol
This commit is contained in:
25
vendor/nhooyr.io/websocket/internal/xsync/go.go
generated
vendored
Normal file
25
vendor/nhooyr.io/websocket/internal/xsync/go.go
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user