Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
git.fd.io/govpp.git
⚠️ The GoVPP project is changing hosting :
The last version archived on git.fd.io/govpp.git will be v0.5.0
.
The GoVPP repository contains a Go client library for interacting with the VPP, generator of Go bindings for the VPP binary API and various other tooling for VPP.
Here is a brief overview for the repository structure.
Below are some code examples showing GoVPP client interacting with VPP API.
Here is a code for low-level way to access the VPP API using the generated messages directly for sending/receiving.
package main
import (
"log"
"git.fd.io/govpp.git"
"git.fd.io/govpp.git/binapi/interfaces"
"git.fd.io/govpp.git/binapi/vpe"
)
func main() {
// Connect to VPP
conn, _ := govpp.Connect("/run/vpp/api.sock")
defer conn.Disconnect()
// Open channel
ch, _ := conn.NewAPIChannel()
defer ch.Close()
// Prepare messages
req := &vpe.ShowVersion{}
reply := &vpe.ShowVersionReply{}
// Send the request
err := ch.SendRequest(req).ReceiveReply(reply)
if err != nil {
log.Fatal("ERROR: ", err)
}
log.Print("Version: ", reply.Version)
}
For a complete example see simple-client.
Here is a sample code for an effortless way to access the VPP API using a generated RPC service client for calling.
package main
import (
"context"
"log"
"git.fd.io/govpp.git"
"git.fd.io/govpp.git/binapi/vpe"
)
func main() {
// Connect to VPP API socket
conn, _ := govpp.Connect("/run/vpp/api.sock")
defer conn.Disconnect()
// Init vpe service client
client := vpe.NewServiceClient(conn)
reply, err := client.ShowVersion(context.Background(), &vpe.ShowVersion{})
if err != nil {
log.Fatal("ERROR: ", err)
}
log.Print("Version: ", reply.Version)
}
For a complete example see rpc-service.
More examples can be found in examples directory.
Further documentation can be found in docs directory.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.