Created
August 11, 2018 08:08
-
-
Save pasdam/d05af20fdb57da156af62ea914396611 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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