summaryrefslogtreecommitdiff
path: root/toolkit/andlabs/process.go
blob: d70877e83a6e3bf8a3e2d48c7c2635e5ab906343 (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// myplugin/myplugin.go
package main

/*
from chatgpt:

// put this in widget.go
import (
    "fmt"
    // "toolkit"
)

type Plugin interface {
    Process(input chan string, output chan string)
}

// put this in wit/gui/toolkit/*
type myPlugin struct{}

var Plugin myPlugin

func (p *myPlugin) Process(input chan string, output chan string) {
    go func() {
        for msg := range input {
            // Your processing logic goes here
            result := fmt.Sprintf("Processed: %s", msg)
            output <- result
        }
    }()
}

// main.go put this in wit/gui
package main

import (
    "fmt"
    "plugin"
    "pluginapi"
)

func main() {
    plug, err := plugin.Open("myplugin.so")
    if err != nil {
        panic(err)
    }

    symPlugin, err := plug.Lookup("Plugin")
    if err != nil {
        panic(err)
    }

    p, ok := symPlugin.(pluginapi.Plugin)
    if !ok {
        panic("Invalid plugin type")
    }

    input := make(chan string)
    output := make(chan string)

    p.Process(input, output)

    input <- "Hello, World!"
    close(input)

    for result := range output {
        fmt.Println(result)
    }
}

*/

// func main() {}