Skip to content

Unmarshalling to an interface type? #95

@prologic

Description

@prologic

It this supported? For example:

// 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() 🤔

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions