package main
import (
"log"
"time"
"github.com/valyala/gorpc"
)
func main() {
go func() {
s := &gorpc.Server{
// Accept clients on this TCP address.
Addr: "0.0.0.0:12345",
// Echo handler - just return back the message we received from the client
Handler: func(clientAddr string, request interface{}) interface{} {
log.Printf("Obtained request %+v from the client %s\n", request, clientAddr)
return request
},
}
if err := s.Serve(); err != nil {
log.Fatalf("Cannot start rpc server: %s", err)
}
}()
c := &gorpc.Client{
// TCP address of the server.
Addr: "127.0.0.1:12345",
}
c.Start()
time.Sleep(3 * time.Second)
// All client methods issuing RPCs are thread-safe and goroutine-safe,
// i.e. it is safe to call them from multiple concurrently running goroutines.
resp, err := c.Call("foobar")
if err != nil {
log.Fatalf("Error when sending request to server: %s", err)
}
if resp.(string) != "foobar" {
log.Fatalf("Unexpected response from the server: %+v", resp)
}
log.Printf("resp: %v", resp)
}
Use go1.9, and build with GOARCH=arm GOARM=7 GOOS=linux go build -o testgorpc ./main.go
Run testgorpc and get panic as the client connects to the server.
Hi,
As title, it seems to relate to https://github.com/golang/go/issues/23345. Is there any way to avoid this problem?
Here is my test steps.
GOARCH=arm GOARM=7 GOOS=linux go build -o testgorpc ./main.go
testgorpc
and get panic as the client connects to the server.