Skip to content

yankewei/delay_msg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

delay_msg

a delay message package build with go

想法来自于看的一篇微信公众号的文章《如何快速实现“延时消息”》。觉得还挺有趣的,就想实现一个看看。

Usage

The first need Go installed (version 1.11+ is required), then you can use the below Go command to install:

go get -u github.com/yankewei/delay_msg
package main

import (
	"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 ***"。

About

a delay message package build with go

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages