MCPcopy
hub / github.com/coder/websocket / Go

Function Go

internal/xsync/go.go:10–26  ·  view source on GitHub ↗

Go allows running a function in another goroutine and waiting for its error.

(fn func() error)

Source from the content-addressed store, hash-verified

8// Go allows running a function in another goroutine
9// and waiting for its error.
10func Go(fn func() error) <-chan error {
11 errs := make(chan error, 1)
12 go func() {
13 defer func() {
14 r := recover()
15 if r != nil {
16 select {
17 case errs <- fmt.Errorf("panic in go fn: %v, %s", r, debug.Stack()):
18 default:
19 }
20 }
21 }()
22 errs <- fn()
23 }()
24
25 return errs
26}

Callers 9

TestConnFunction · 0.92
goEchoLoopMethod · 0.92
goDiscardLoopMethod · 0.92
assertEchoFunction · 0.92
TestConcurrentClosePingFunction · 0.92
TestConnClosePropagationFunction · 0.92
ServeHTTPMethod · 0.92
EchoFunction · 0.92
TestGoRecoverFunction · 0.85

Calls

no outgoing calls

Tested by 8

TestConnFunction · 0.74
goEchoLoopMethod · 0.74
goDiscardLoopMethod · 0.74
assertEchoFunction · 0.74
TestConcurrentClosePingFunction · 0.74
TestConnClosePropagationFunction · 0.74
ServeHTTPMethod · 0.74
TestGoRecoverFunction · 0.68