Code Monkey home page Code Monkey logo

go-bind-plugin's Introduction

Hi there stranger ๐Ÿ‘‹

My name is Mateusz 'Serafin' Gajewski and I'm a Staff Software Engineer at Starburst Data which is a company behind the development of the Trino query engine (a.k.a. PrestoSQL)

You can find more details about me on my website wendigo.pl.

Feel free to reach me if you want to ask me about anything ๐Ÿ™‚

go-bind-plugin's People

Contributors

wendigo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

go-bind-plugin's Issues

Generates wrong code

with this plugin it seems to generate wrong code :(

package main

import (
	"C"
	"fmt"
	"gitlab.com/IRSH/irshGoFramework/plugins/types"
)

// pluginName of the Web Plugin
const PluginName = "web"

type PluginStruct struct {
	types.DefaultPlugin
}

func (p PluginStruct) Greet() {
	fmt.Println("Hello Universe")
}

// Define Plugin (Web=false as it otherwise would create a dependency loop)
var Plugin = PluginStruct{
	DefaultPlugin: types.NewDefaultPlugin(PluginName, false),
}

The result code is

package main

// Autogenerated by github.com/wendigo/go-bind-plugin on 2017-08-10 16:28:47.266724012 +0000 UTC, do not edit!
// Command: go-bind-plugin -plugin-path ../../../../plugins/web.so -plugin-package ./plugins -output-name WebPlugin -output-path ./plugin_api.go -output-package main -dereference-vars -rebuild
//
// Plugin ../../../../plugins/web.so info:
// - package: gitlab.com/IRSH/irshGoFramework/plugins
// - size: 3181200 bytes
// - sha256: cbd1f0c407ac3405ea31b0ab692cc397c1ef4bbbe33c1d82d46059b9a761117c

import (
        "fmt"
        "main"
        "plugin"
        "reflect"
        "strings"
)

// WebPlugin wraps symbols (functions and variables) exported by plugin gitlab.com/IRSH/irshGoFramework/plugins
//
// See docs at https://godoc.org/gitlab.com/IRSH/irshGoFramework/plugins
type WebPlugin struct {
        // Exported functions

        // Exported variables (public references)

        // See docs at https://godoc.org/gitlab.com/IRSH/irshGoFramework/plugins#Plugin
        Plugin main.PluginStruct
}

// String returnes textual representation of the wrapper. It provides info on exported symbols and variables.
func (p *WebPlugin) String() string {
        var lines []string
        lines = append(lines, "Struct WebPlugin:")
        lines = append(lines, "\t- Generated on: 2017-08-10 16:28:47.266724012 +0000 UTC")
        lines = append(lines, "\t- Command: go-bind-plugin -plugin-path ../../../../plugins/web.so -plugin-package ./plugins -output-name WebPlugin -output-path ./plugin_api.go -output-package main -dereference-vars -rebuild")
        lines = append(lines, "\nPlugin info:")
        lines = append(lines, "\t- package: gitlab.com/IRSH/irshGoFramework/plugins")
        lines = append(lines, "\t- sha256 sum: cbd1f0c407ac3405ea31b0ab692cc397c1ef4bbbe33c1d82d46059b9a761117c")
        lines = append(lines, "\t- size: 3181200 bytes")
        lines = append(lines, "\nExported functions (0):")

        lines = append(lines, "\nExported variables (1):")
        lines = append(lines, "\t- Plugin main.PluginStruct")

        return strings.Join(lines, "\n")
}

// BindWebPlugin loads plugin from the given path and binds symbols (variables and functions)
// to the WebPlugin struct. All variables are derefenenced.
func BindWebPlugin(path string) (*WebPlugin, error) {
        p, err := plugin.Open(path)

        if err != nil {
                return nil, fmt.Errorf("could not open plugin: %s", err)
        }

        ret := new(WebPlugin)

        varPlugin, err := p.Lookup("Plugin")
        if err != nil {
                return nil, fmt.Errorf("could not import variable 'Plugin', symbol not found: %s", err)
        }

        if typed, ok := varPlugin.(*main.PluginStruct); ok {
                ret.Plugin = *typed
        } else {
                return nil, fmt.Errorf("could not import variable 'Plugin', incompatible types 'main.PluginStruct' and '%s'", reflect.TypeOf(varPlugin))
        }

        return ret, nil
}

for some reason it tries to get PluginStruct from main but it needs to be more or less copied over.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.