vppapisamples icon indicating copy to clipboard operation
vppapisamples copied to clipboard

Golang API cannot find package

Open kongyanye opened this issue 4 years ago • 2 comments

Hi marosmars,

Thanks for sharing your blog and example scripts. I'm currently trying to use the GO version VPP api from https://github.com/fdio/govpp. I've installed the VPP binaries on Ubuntu 20 (including the vpp-dev optional package) and followed their official github repo to install the GO package. But I can't successfully run neither their quick start script nor your example script.

There are mainly two problems:

  1. Seems the API structure is broken. I successfully installed binapi-generator and generated the GO bindings, and then put the generated files under $GOROOT/vppapi (/usr/local/go/src/vppapi). After that, when importing package "interfaces" and "l2", it shows error "cannot find package std/std/vppapi/ethernet_types" and several other packages like "ip_types" and "vpe". These packages indeed exist under $GOROOT/vppapi, but GO seems can't find it because they automatically add the "std/std" prefix before module name. How can I fix it?

  2. The package "interfaces" actually does not exist (you can check it in their official example and repo files), but there do exist a package called "interface". I don't know how it can be imported.

Their official repo does not provide the issue function and there are almost no materials I can find online to use VPP api in GO. So I ask the question here. I would really appreciate it if you can give me some insights. Thanks!

kongyanye avatar Mar 11 '21 11:03 kongyanye

you'd first build the bin-api using command like,

cd $GOPATH/src/git.fd.io/govpp.git binapi-generator --output-dir=binapi

the binapi locates at, $GOPATH/src/git.fd.io/govpp.git/binapi

pan2za avatar Apr 04 '21 02:04 pan2za

I figured out the problem. The api source file should be placed under $GOPATH/src/git.fd.io/govpp.git and the new packages is indeed called "interfaces" instead of "interface".

kongyanye avatar Apr 04 '21 10:04 kongyanye