filecoin-project / filecoin-project/go-jsonrpc

Unmarshalling to an interface type?

Open
#95 1 comment 0 reactions 0 assignees View on GitHub
enhancement good first issue help wanted
Dominant language
Go
Stars
100
Forks
95
PR merge metrics
No merged PRs in 30d

Description

It this supported? For example:

```go
// Package main implements a test JSON-RPC cli client
package main

import (
"context"
"flag"
"fmt"
"net"
"net/http"

"github.com/filecoin-project/go-jsonrpc"
"go.mills.io/saltyim"
)

func main() {
flag.Parse()

httpc := &http.Client{
Transport: &http.Transport{
DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
return net.Dial("unix", flag.Arg(0))
},
},
}

var cli struct {
Me func() saltyim.Addr
String func() string
}

closer, err := jsonrpc.NewMergeClient(
context.Background(),
"http://example.com",
"Client",
[]any{&cli},
nil,
jsonrpc.WithHTTPClient(httpc),
)
if err != nil {
panic(err)
}
defer closer()

fmt.Printf("String():\n%s\n", cli.String())

me := cli.Me()
fmt.Printf("Me(): #%v\n", me)
}
```

Currently I get `nil` for a call to `cli.me()` 🤔

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.