package main import ( "io" "net/http" "net/rpc" "net/rpc/jsonrpc" ) type HelloService struct { } func (p *HelloService) Hello(request string, reply *string) error { *reply = "Hello:" + request return nil } func main() { rpc.RegisterName("HelloService", new(HelloService)) http.HandleFunc("/jsonrpc", func(w http.ResponseWriter, r *http.Request) { var conn io.ReadWriteCloser = struct { io.Writer io.ReadCloser }{ w, r.Body, } rpc.ServeRequest(jsonrpc.NewServerCodec(conn)) }) http.ListenAndServe(":7777", nil) }