mirror of
https://github.com/chai2010/advanced-go-programming-book.git
synced 2025-05-24 20:52:22 +00:00
32 lines
480 B
Go
32 lines
480 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
|
|
"gobook.examples/ch4-01-rpc-intro/hello-service-v2/api"
|
|
)
|
|
|
|
type HelloService struct{}
|
|
|
|
func (p *HelloService) Hello(request string, reply *string) error {
|
|
*reply = "hello:" + request
|
|
return nil
|
|
}
|
|
|
|
func main() {
|
|
|
|
client, err := api.DialHelloService("tcp", "localhost:1234")
|
|
if err != nil {
|
|
log.Fatal("dialing:", err)
|
|
}
|
|
|
|
var reply string
|
|
err = client.Hello("hello", &reply)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
fmt.Println(reply)
|
|
}
|