hashicorp / hashicorp/go-plugin
Passing struct parameter
- Dominant language
- Go
- Stars
- 6.1k
- Forks
- 511
- Avg merge
- 22h 47m
- Merged PRs (30d)
- 4
Description
How am I suppose to pass a struct argument to the `basic` rpc example?
So far I did that and got the panic shown in the comment:
```golang
type Arg struct {
Name string
}
type Greeter interface {
Greet(*Arg) string
}
type GreeterRPC struct{ client *rpc.Client }
func (g *GreeterRPC) Greet(args *Arg) string {
var resp string
err := g.client.Call("Plugin.Greet", args, &resp)
if err != nil {
// panic: gob: local interface type *interface {} can only be decoded
// from remote interface type; received concrete type Arg
panic(err)
}
return resp
}
```
I'm not very familiar with rpc but the `net/rpc` package tests works and are pretty straightforward.
```golang
args = &Args{7, 8}
reply = new(Reply)
err = client.Call("Arith.Mul", args, reply)
```
Am I missing something?
Contributor guide
Assessment
This issue has not been assessed yet.