package example import ( "fmt" "log" "golang.org/x/net/context" "google.golang.org/grpc" apiclient "src.dualinventive.com/go/companies-service/grpc" ) func Example_grpc() { var target = "api.mtinfo3000.com:8063" // Change target (host:port) to connect to here var companyid uint64 = 1 // Change CompanyID to be requested here var conn *grpc.ClientConn conn, dialerr := grpc.Dial(target, grpc.WithInsecure()) if dialerr != nil { log.Fatalf("Error when connecting: %s", dialerr) } defer func() { if closeerr := conn.Close(); closeerr != nil { log.Fatalf("Error when closing: %s", closeerr) } }() client := apiclient.NewCompaniesServiceClient(conn) response, geterr := client.GetCompanyByID(context.Background(), &apiclient.GetCompanyByIDRequest{CompanyID: companyid}) if geterr != nil { log.Fatalf("Error when calling GetCompanyByID: %s", geterr) } fmt.Printf("%s\n", response.Company) // Prefix the line below with 'Output: ' to actually run the test and check the output // companyID:1 companyCode:"system" companyName:"SYSTEM" }