Skip to content

plugin: build path contributes to types not equal #19233

Closed
@zhangxu19830126

Description

@zhangxu19830126

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

1.8

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/opt/lib/go-path"
GORACE=""
GOROOT="/opt/lib/go"
GOTOOLDIR="/opt/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build171911883=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

I want to use custom interface based on go plugin, but i found it's not support.

func newExternalFilter(filterSpec *conf.FilterSpec) (filter.Filter, error) {
        p, err := plugin.Open(filterSpec.ExternalPluginFile)
        if err != nil {
            return nil, err
        }

        s, err := p.Lookup("NewExternalFilter")
        if err != nil {
            return nil, err
        }

        sf := s.(func() (filter.Filter, error))
        return sf()
    }

    // NewExternalFilter create a External filter
    func NewExternalFilter() (filter.Filter, error) {
        return &AccessFilter{}, nil
    }

What did you expect to see?

I expect this operation will success.

What did you see instead?

panic: interface conversion: plugin.Symbol is func() (filter.Filter, error), not func() (filter.Filter, error)

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions