Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 4, part 17, Server #20

Open
davidka79 opened this issue Jul 26, 2021 · 2 comments
Open

Chapter 4, part 17, Server #20

davidka79 opened this issue Jul 26, 2021 · 2 comments

Comments

@davidka79
Copy link

Hello
I am trying to study your course, but I can not pass a 17th path of the Lesson
First protoc format and keys was changed and I was needed to read a documentation for update keys and set the full path for package.

For now I am trying to follow a simple add listener and getting error
server.go

package main

import (
	"fmt"
	"github.com/davidka79/go-grp-study/greet/greetpb"
	"google.golang.org/grpc"
	"log"
	"net"
)

type server struct {}


func main() {
	fmt.Println("Hello World")

	lis, err := net.Listen("tcp", "0.0.0.0:50051")
	if err != nil {
		log.Fatalf("Failed %v", err)
	}
	s := grpc.NewServer()
	greetpb.RegisterGteetServiceServer(s, &server{})

	if err := s.Serve(lis); err != nil {
		log.Fatalf("Failed to serve %v", err)
	}
}

here at greetpb.RegisterGteetServiceServer(s, &server{}) the error that *"Cannot use '&server{}' (type server) as the type GteetServiceServer Type does not implement 'GteetServiceServer' as some methods are missing: mustEmbedUnimplementedGteetServiceServer()"

I tried many ways but still not succeed, probably need to update code, but I do not know what to do

@davidka79
Copy link
Author

as far as greetpb.UnimplementedGteetServiceServer it is a type, this way is working

var server greetpb.UnimplementedGteetServiceServer

@efemrL
Copy link

efemrL commented Nov 24, 2021

Update the struct as follows:

  type server struct {
   greetpb.UnimplementedGreetServiceServer
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants