Skip to content

Instantly share code, notes, and snippets.

@pasdam
Created August 11, 2018 08:08
Show Gist options
  • Save pasdam/d05af20fdb57da156af62ea914396611 to your computer and use it in GitHub Desktop.
Save pasdam/d05af20fdb57da156af62ea914396611 to your computer and use it in GitHub Desktop.
package main
import (
"log"
"net"
"../gen/go"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
type greetingServer struct {
}
// Returns a greeting message
func (g *greetingServer) Hello(ctx context.Context, r *example.GreetingRequest) (*example.GreetingReply, error) {
log.Println("Hello called")
return &example.GreetingReply{Text: "Hello " + r.Name}, nil
}
func main() {
lis, err := net.Listen("tcp", "localhost:9001")
if err != nil {
panic(err)
}
log.Println("Starting server")
s := grpc.NewServer()
example.RegisterGreeterServer(s, &greetingServer{})
s.Serve(lis)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment