예제 #1
0
func ExampleTransformer() {
	upper := flow.Transformer(func(m flow.Message) flow.Message {
		return strings.ToUpper(m.(string))
	})

	g := flow.NewCircuit()
	g.AddCircuitry("u", upper)
	g.Feed("u.In", "abc")
	g.Feed("u.In", "def")
	g.Run()
	// Output:
	// Lost string: ABC
	// Lost string: DEF
}
예제 #2
0
func ExampleIntelHexToBin() {
	g := flow.NewCircuit()
	g.Add("r", "ReadFileText")
	g.Add("b", "IntelHexToBin")
	g.AddCircuitry("n", flow.Transformer(func(m flow.Message) flow.Message {
		if v, ok := m.([]byte); ok {
			m = len(v)
		}
		return m
	}))
	g.Connect("r.Out", "b.In", 0)
	g.Connect("b.Out", "n.In", 0)
	g.Feed("r.In", "./blinkAvr1.hex")
	g.Run()
	// Output:
	// Lost flow.Tag: {<open> ./blinkAvr1.hex}
	// Lost flow.Tag: {<addr> 0}
	// Lost int: 726
	// Lost flow.Tag: {<close> ./blinkAvr1.hex}
}