summaryrefslogtreecommitdiff
path: root/toolkit/andlabs/process.go
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/andlabs/process.go')
-rw-r--r--toolkit/andlabs/process.go72
1 files changed, 72 insertions, 0 deletions
diff --git a/toolkit/andlabs/process.go b/toolkit/andlabs/process.go
new file mode 100644
index 0000000..d70877e
--- /dev/null
+++ b/toolkit/andlabs/process.go
@@ -0,0 +1,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() {}