项目作者: Code-Hex

项目描述 :
context with signal in golang
高级语言: Go
项目地址: git://github.com/Code-Hex/sigctx.git
创建时间: 2017-04-07T11:39:45Z
项目社区:https://github.com/Code-Hex/sigctx

开源协议:MIT License

下载


sigctx

Signal for context.Context.

GoDoc
Build Status
Coverage Status
Go Report Card

Description

The package sigctx were developed to easily bind signals and context.Context.

We use a combination of signals and context.Context often. It is mainly processing to context cancel after receiving the signal. Using this package makes it easy to do it.
Example: signal_cancel.go

By the way, if you are using the context, have you ever wanted to send the signal to all the goroutines? You are lucky 🎉 With this package, it is possible to do something close to that.
Example: notify_signal.go

Do you want to run the above two methods at the same time? Of course you can do it.
However, it becomes complicated if you mistake order. (Perhaps this problem may be fixed in the future.) But it will be very simple if the order of invocation is correct!!
I recommend comparing mistake_ctx_order.go and correct_ctx_order.go.

Install

  1. go get github.com/Code-Hex/sigctx

Contributing

Welcome!!
I’m waiting for pull requests or reporting issues.

License

MIT

Author

CodeHex