github.com/godevsig/adaptiveservice@v0.9.23/examples/hello/client/helloclient.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  
     6  	as "github.com/godevsig/adaptiveservice"
     7  	msg "github.com/godevsig/adaptiveservice/examples/hello/message"
     8  )
     9  
    10  func main() {
    11  	c := as.NewClient()
    12  
    13  	conn := <-c.Discover("example", "hello")
    14  	if conn == nil {
    15  		fmt.Println(as.ErrServiceNotFound("example", "hello"))
    16  		return
    17  	}
    18  	defer conn.Close()
    19  
    20  	request := msg.HelloRequest{Who: "John", Question: "who are you"}
    21  	var reply msg.HelloReply
    22  	if err := conn.SendRecv(request, &reply); err != nil {
    23  		fmt.Println(err)
    24  		return
    25  	}
    26  	fmt.Println(reply.Answer)
    27  }