feat(global):全局增加一个用于生成带有超时控制的上下文生成器。

This commit is contained in:
徐涛 2022-09-15 16:14:30 +08:00
parent ae6e6490b2
commit b262042244

10
global/context.go Normal file
View File

@ -0,0 +1,10 @@
package global
import (
"context"
"time"
)
func TimeoutContext(timeout time.Duration) (context.Context, context.CancelFunc) {
return context.WithTimeout(context.Background(), timeout)
}