https://github.com/yankewei/delay_msg
a delay message package build with go
https://github.com/yankewei/delay_msg
delay-messages go
Last synced: 4 months ago
JSON representation
a delay message package build with go
- Host: GitHub
- URL: https://github.com/yankewei/delay_msg
- Owner: yankewei
- License: apache-2.0
- Created: 2020-05-05T10:48:49.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-15T10:58:48.000Z (about 5 years ago)
- Last Synced: 2025-01-05T19:18:35.713Z (5 months ago)
- Topics: delay-messages, go
- Language: Go
- Size: 14.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# delay_msg
a delay message package build with go想法来自于看的一篇微信公众号的文章[《如何快速实现“延时消息”》](https://mp.weixin.qq.com/s/9qt3JEvjv1wka57GBTng9g)。觉得还挺有趣的,就想实现一个看看。
### Usage
The first need Go installed (version 1.11+ is required), then you can use the below Go command to install:
```bash
go get -u github.com/yankewei/delay_msg
``````go
package mainimport (
"fmt"
"github.com/yankewei/delay_msg"
"time"
)type Hello struct {
}
func (h *Hello) Greet(name string) {
fmt.Println("Welcome " + name)
}func main() {
r := delay_msg.GetDelayMessageApp()
r.AddMessage(new(Hello), "Greet", 10 * time.Second, "yankewei")
r.Run()
}
```
copy above code to a file, then run `go run example.go` and wait 10 seconds.
If correct, you can see a string "Welcome ***"。