123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package main
- import (
- "bytes"
- "hexasoftware/lib/bench"
- _ "hexasoftware/lib/prettylog/global"
- "hexasoftware/lib/vnode"
- "log"
- )
- // Test 1 Sum 2 numbers
- // The goal:
- /*
- GetInput(1).Link(othervnode)
- */
- func sumFunc(a, b int) int {
- return a + b
- }
- func sumFuncV(args ...interface{}) interface{} {
- return args[0].(int) + args[1].(int)
- }
- func ret10() int {
- return 10
- }
- func main() {
- reverse := vnode.New(func(s string) string {
- var b bytes.Buffer
- for i := len(s) - 1; i >= 0; i-- {
- b.WriteByte(s[i])
- }
- return b.String()
- })
- reverse.Source("Hello from the other side")
- count := vnode.New(func(s string) int {
- return len(s)
- })
- count.Source("This is a big string")
- log.Println(reverse.Exec())
- sumNode1 := vnode.New(sumFunc, 2)
- var err error
- err = sumNode1.Source(count, ret10)
- log.Println("Error check", err)
- sumNode := vnode.New(sumFunc, 2)
- err = sumNode.Source(sumNode1, 2)
- log.Println("Error check", err)
- log.Println("Node:", sumNode.Exec())
- log.Printf("Func done")
- bench.Exec("main", func() interface{} {
- return sumNode.Exec()
- })
- }
|