Skip to content

Instantly share code, notes, and snippets.

@rezaramadhanirianto
Created February 2, 2022 08:22
Show Gist options
  • Select an option

  • Save rezaramadhanirianto/09b6e1092d7236877423939623261f05 to your computer and use it in GitHub Desktop.

Select an option

Save rezaramadhanirianto/09b6e1092d7236877423939623261f05 to your computer and use it in GitHub Desktop.
package main
import (
"context"
"fmt"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"grpc/my-simple-grpc/output"
"time"
)
const address = "localhost:8080"
func main() {
conn, err := grpc.Dial(address, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock())
if err != nil {
fmt.Println("did not connect: ", err)
}
defer conn.Close()
outputService := output.NewOutputServiceClient(conn)
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
outputRequest := &output.OutputRequest{
Title: "GOGOGO",
}
_, err = outputService.SendOutput(ctx, outputRequest)
if err != nil {
fmt.Println("error send output: ", err)
}
fmt.Println("success send output: ", outputRequest.Title)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment