MCPcopy Create free account
hub / github.com/goinaction/code / main

Function main

chapter10/listing06/listing06.go:34–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32}
33
34func main() {
35
36 // Create a slice of publisher interface values. Assign
37 // the address of a pubsub.PubSub value and the address of
38 // a mock value.
39 pubs := []publisher{
40 pubsub.New("localhost"),
41 &mock{},
42 }
43
44 // Range over the interface value to see how the publisher
45 // interface provides the level of decoupling the user needs.
46 // The pubsub package did not need to provide the interface type.
47 for _, p := range pubs {
48 p.Publish("key", "value")
49 p.Subscribe("key")
50 }
51}

Callers

nothing calls this directly

Calls 2

PublishMethod · 0.65
SubscribeMethod · 0.65

Tested by

no test coverage detected