/usr/share/gocode/src/github.com/cenk/hub/example_test.go is in golang-github-cenk-hub-dev 1.0.0+git20160321.17.b864404b5f99-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | package hub_test
import (
"fmt"
"github.com/cenk/hub"
)
// Different event kinds
const (
happenedA hub.Kind = iota
happenedB
happenedC
)
// Our custom event type
type EventA struct {
arg1, arg2 int
}
// Implement hub.Event interface
func (e EventA) Kind() hub.Kind { return happenedA }
func Example() {
hub.Subscribe(happenedA, func(e hub.Event) {
a := e.(EventA) // Cast to concrete type
fmt.Println(a.arg1 + a.arg2)
})
hub.Publish(EventA{2, 3})
// Output: 5
}
|