-
-
Save ruandao/1e4d8f4d6c5d05554b802036a3984ae3 to your computer and use it in GitHub Desktop.
2018/07/06 18:10:51 call err: gob: type not registered for interface: map[string]interface {}
panic: call err: gob: type not registered for interface: map[string]interface {} 确定原因是,map赋值给interface{}字段 也就是说,rpc调用不支持interface{}字段咯
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net/rpc" | |
"log" | |
"fmt" | |
) | |
func failOnErr(err error, s string) { | |
if err != nil { | |
s := fmt.Sprintf("%s: %s", s, err) | |
log.Print(s) | |
panic(s) | |
} | |
} | |
type Args struct { | |
X interface{} | |
} | |
type Reply struct { | |
} | |
func main() { | |
conn, err := rpc.Dial("tcp", ":9876") | |
failOnErr(err, "dail fail") | |
args := Args{ | |
X:map[string]interface{}{}, | |
} | |
reply := &Reply{} | |
err = conn.Call("R.T", args, reply) | |
failOnErr(err, "call err") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment