From ed382bec55be25039e4dcf020d1512139855c9bb Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 9 Nov 2022 08:38:50 -0600 Subject: cleanup of the example commands. more plugin work add a button in two plugins at the same time! added a button in andlabs/ui & gocui attempt a common widget struct between wit/gui & the plugins start handling missing plugins rename Makefile command examples remote examples used for testing filename improvements golang src code uses lowercase and _ in filenames fix crash when button click function == nil fix wrong name 'gocli' -> 'gocui' keep fighting with goreadme generated README.md Signed-off-by: Jeff Carr --- cmds/gocli-as-plugin/main.go | 59 -------------------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 cmds/gocli-as-plugin/main.go (limited to 'cmds/gocli-as-plugin/main.go') diff --git a/cmds/gocli-as-plugin/main.go b/cmds/gocli-as-plugin/main.go deleted file mode 100644 index a9bd632..0000000 --- a/cmds/gocli-as-plugin/main.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2014 The gocui Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -import ( - "log" - "os" - - "plugin" -// "github.com/awesome-gocui/gocui" -) - -type Greeter interface { - Greet() -} - -var plugGocli *plugin.Plugin -var plugHello *plugin.Plugin - -func main() { - log.Println("attempt plugin") - - go loadPlugin(plugHello, "../../toolkit/hello.so") - loadPlugin(plugGocli, "../../toolkit/gocli.so") -} - -func loadPlugin(plug *plugin.Plugin, name string) { - // load module - // 1. open the so file to load the symbols - plug, err = plugin.Open(name) - if err != nil { - log.Println(err) - os.Exit(1) - } - - // 2. look up a symbol (an exported function or variable) - // in this case, variable Greeter - symGreeter, err := plug.Lookup("Greeter") - if err != nil { - log.Println(err) - os.Exit(1) - } - - log.Println("symGreater", symGreeter) - - // 3. Assert that loaded symbol is of a desired type - // in this case interface type Greeter (defined above) - // var greeter Greeter - greeter, ok := symGreeter.(Greeter) - if !ok { - log.Println("unexpected type from module symbol") - os.Exit(1) - } - - // 4. use the module - greeter.Greet() -} -- cgit v1.2.3