Skip to content

go-events 是一个 go 实现的事件及事件过滤器库 / go-event is a go event pkg, like wordpress hook functions

License

Notifications You must be signed in to change notification settings

deatil/go-events

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-events

Go Reference

Desc

  • go-events is a go event and event'subscribe pkg, like wordpress hook functions.

中文 | English

Download

go get -u github.com/deatil/go-events

Get Starting

package main

import (
    "fmt"
    "github.com/deatil/go-events/events"
)

func main() {
    // use action
    events.AddAction("test1", func() {
        fmt.Println("test1")
    }, events.DefaultSort)

    events.DoAction("test1")

    // use Filter
    events.AddFilter("test1", func(val string) string {
        return "run test1 => " + val
    }, events.DefaultSort)

    data1 := "init1"
    test := events.ApplyFilters("test1", data1)

    fmt.Println(test)
    // output: run test1 => init1
}

LICENSE

  • The library LICENSE is Apache2, using the library need keep the LICENSE.

Copyright