mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-11 07:03:32 +08:00

- Modified Godeps/Godeps.json by hand - [TEST] Updated welcome docs hash to sharness - [TEST] Updated contact doc - [TEST] disabled breaking test (t0080-repo refs local)
23 lines
351 B
Go
23 lines
351 B
Go
package util
|
|
|
|
import "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
|
|
|
|
func ContextDo(ctx context.Context, f func() error) error {
|
|
|
|
ch := make(chan error)
|
|
|
|
go func() {
|
|
select {
|
|
case <-ctx.Done():
|
|
case ch <- f():
|
|
}
|
|
}()
|
|
select {
|
|
case <-ctx.Done():
|
|
return ctx.Err()
|
|
case val := <-ch:
|
|
return val
|
|
}
|
|
return nil
|
|
}
|