Beginners Guide to gRPC in Go!

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ม.ค. 2025

ความคิดเห็น • 97

  • @Tutorialedge
    @Tutorialedge  3 ปีที่แล้ว +6

    Hi Folks! If you are interested, I'm currently developing a new course - building a gRPC Microservice in Go which you can find here - tutorialedge.net/courses/go-grpc-services-course/
    This covers everything from project setup and layout, testing, and best practices around things like versioning.

  • @nicolotafta7150
    @nicolotafta7150 7 หลายเดือนก่อน +3

    Has been past 4 years but most well done video on the gRPC! gj

  • @wkdj2522
    @wkdj2522 ปีที่แล้ว +1

    extremely well done. i had no idea what gRPC was; now i do. thanks!

  • @ericb252
    @ericb252 3 ปีที่แล้ว +3

    This is invaluable. This really helps so many of us. Thank you!

  • @alpaslaneldemir6904
    @alpaslaneldemir6904 4 ปีที่แล้ว +10

    Thanks for the Tutorial. A stream example would be a nice one for next. Broadcasting a gıven message to all connected clients.

  • @GodofStories
    @GodofStories ปีที่แล้ว

    Great tutorial. Appreciate your video, and some of the other helpful comments

  • @alexveeuk
    @alexveeuk 4 ปีที่แล้ว +16

    This was a very useful tutorial thank you 👌! I would be grateful if you could you show us stream examples and maybe connecting it to MongoDB with how to bind them to primitives using todos as an example would be awesome!

    • @ixaran
      @ixaran 4 ปีที่แล้ว

      are you mobile developer?

  • @WaldirBorbaJunior
    @WaldirBorbaJunior 4 ปีที่แล้ว +2

    Amazing content. tks for sharing

  • @pedroramos5715
    @pedroramos5715 3 ปีที่แล้ว +2

    Thanks for this.

  • @Omar-hw7zi
    @Omar-hw7zi 3 ปีที่แล้ว +1

    Thanks, very simple example. Straight to the point!

  • @albinbackstrom9297
    @albinbackstrom9297 2 ปีที่แล้ว +10

    I could not get the protoc command work from this video. Had to run it like this: protoc -I. --go_out=. --go-grpc_out=require_unimplemented_servers=false:. chat.proto and also add this to the .proto file option go_package = "./chat";

    • @gdgo6166
      @gdgo6166 2 ปีที่แล้ว +2

      this was helpful! you should be pinned so other people can be unblocked faster

    • @andrewklein3349
      @andrewklein3349 ปีที่แล้ว +2

      banger comment, saved me tearing my hair out

    • @mystica7284
      @mystica7284 ปีที่แล้ว +1

      you are lifesaver dude!! thanks

  • @jordansilva15
    @jordansilva15 3 ปีที่แล้ว

    Thank you for the video, really usefull, there is so few quality learning material on this topic, this tutorial helped me a lot.

  • @mecamon
    @mecamon หลายเดือนก่อน

    Thank you so much!

  • @Rcls01
    @Rcls01 หลายเดือนก่อน

    Kewl. Thanks for clarifying a few things!

  • @chrisreplogle6172
    @chrisreplogle6172 4 ปีที่แล้ว +2

    Thank you for great content!

  • @jayeshthamke7860
    @jayeshthamke7860 4 ปีที่แล้ว +10

    Good work!! Could you bring a tutorial in golang/context package with its real use in application? Thanks

  • @VaibhavPatil-rx7pc
    @VaibhavPatil-rx7pc 4 ปีที่แล้ว +2

    Excellent !!!

  • @grudgemudgen5488
    @grudgemudgen5488 4 ปีที่แล้ว +1

    Excellent tutorial! 👏🏼 I look forward to more from you :-)

  • @politicsmovies6422
    @politicsmovies6422 4 ปีที่แล้ว +3

    tq for this tutorial

  • @Csc5csc5
    @Csc5csc5 3 ปีที่แล้ว +3

    I'm following along and ran into some issues: using go v1.16 in VSCode with the go helpers installed.
    At 10:39 I'm being told that *Message is not defined. It's my understanding that the `package chat` declaration in both the chat.go and chat.pb.go meant that no import was required.
    Further, at 13:25 line 21 I'm being told RegisterChatServiceServer is not declared by the chat package. The package is definitely imported, as autocomplete suggested the method.
    Is there something happening due to differing versions of Go between the video here and what I'm using, or do I need to look for issues elsewhere?

    • @Csc5csc5
      @Csc5csc5 3 ปีที่แล้ว +4

      Figured out half of it - chat.proto requires a line:
      `option go_package = ".;chat";` to be included.
      Still stuck on server.go ln 21: passing &s into RegisterChatServiceServer, but I'm sure I'll figure it out.

    • @sreerampanigrahi
      @sreerampanigrahi 2 ปีที่แล้ว

      @@Csc5csc5 Hey! I've found the fix and putting it here so that it helps someone in future. Basically we need to embed the field. i.e.
      Add this part in the chat.go file and it should work fine
      type Server struct {
      ChatServiceServer
      }

    • @nazarpysko
      @nazarpysko 2 ปีที่แล้ว

      Try compiling the proto file with this command too: protoc --go-grpc_out=./ chat.proto It generates another pb file and it contains all the functions shown on the video. There are few other changes that must be made. Search for my comment for more details.

  • @pedroramos5715
    @pedroramos5715 3 ปีที่แล้ว +5

    I just couldn't generate protoc code without stating explicitly the option "go_package" in my .proto file

    • @georgelza
      @georgelza 3 ปีที่แล้ว +2

      I had the same, it seems the standards have changed, and this is now required, similar to the go.mod that is now compulsory

  • @muzammilsyed2339
    @muzammilsyed2339 ปีที่แล้ว

    Can I get your vscode settings? Theme, font family, line height everything looks very clean

  • @neiluli8329
    @neiluli8329 4 ปีที่แล้ว +2

    Awesome !

  • @vtvvnha2230
    @vtvvnha2230 4 ปีที่แล้ว +4

    how to use grpc with envoy proxy

    • @Tutorialedge
      @Tutorialedge  4 ปีที่แล้ว

      That was just an example, on having a look, there is an excellent go package called grpc-gateway which can act as a proxy for HTTP requests through to your gRPC service - github.com/grpc-ecosystem/grpc-gateway

    • @raco95
      @raco95 4 ปีที่แล้ว

      @@Tutorialedge grpcwebproxy by improbable is a lot easier to use than envoy, not sure about the one you linked but it's worth giving a shot. no extra set up, just list the port of your grpc server and you're good to go github.com/improbable-eng/grpc-web/tree/master/go/grpcwebproxy

  • @codelucky
    @codelucky 4 ปีที่แล้ว +2

    REST VS GRPC VS GRAPHQL?
    Choose one and why?

  • @venil82
    @venil82 4 ปีที่แล้ว +2

    would you store generated pb.go file in git or exclude it?
    how do you share a contract between server and client, and keep them in sync ?

    • @Tutorialedge
      @Tutorialedge  4 ปีที่แล้ว +4

      One approach I've seen used in production environments is to have a monorepo that contains all of your compiled files in every language that teams in your company develop in.
      You then follow appropriate versioning in order to ensure that any breaking changes are done under new versions and don't break existing applications using these compiled files.
      Let me know if this helps! I'm actually planning on doing a more comprehensive series in the near future!

  • @xtapa3271
    @xtapa3271 3 ปีที่แล้ว +1

    If I was to consume an api as a client, I assume I would just look at what the output of the api is (in api documentation e.g.), define my own chat.proto like I would define my own json model struct in rest, and then it just works the same way? And would the chat.Server be my place for dependency injections? If so, this seems so lightweight and convenient.

  • @enjili6062
    @enjili6062 3 ปีที่แล้ว +2

    When I followed, protoc --go_out=. *.proto, I got error below. How should I fix this?
    protoc-gen-go: unable to determine Go import path for "chat.proto"
    Please specify either:
    • a "go_package" option in the .proto source file, or
    • a "M" argument on the command line.

    • @enjili6062
      @enjili6062 3 ปีที่แล้ว +1

      Oh, simply add `option go_package = "example.com/dummy"` would work

    • @otabek7751
      @otabek7751 3 ปีที่แล้ว

      @@enjili6062 ive spent like 5 hrs to solve this...(

    • @empaguia
      @empaguia 3 ปีที่แล้ว +1

      oh hi' @@enjili6062 where to add this?

    • @pinkmmaggit1448
      @pinkmmaggit1448 2 ปีที่แล้ว

      You'd also want to use this URL instead of his for "go mod init" and so on, starting at 10:48

  • @DavidAlsh
    @DavidAlsh 2 ปีที่แล้ว

    So the Go protoc plugin will always generate Go service interface method definitions with context.Context as the first argument?

  • @HSharpknifeedge
    @HSharpknifeedge 2 ปีที่แล้ว

    Thank you !

  • @hanzohasashi3025
    @hanzohasashi3025 2 ปีที่แล้ว +3

    Great video. Btw what vscode theme are you using?

  • @PrashantShekher
    @PrashantShekher 4 ปีที่แล้ว +1

    Great, Do you have any idea run the same code with docker container?

  • @amirhasanbasic2193
    @amirhasanbasic2193 4 ปีที่แล้ว +1

    Would we implement this Sayhello function in the same package chat in produciton, because it seems reasonable that we would implement it in other package so we "hide implementation" from client, this way client could just call the function without having to use RPC... correct me if i'm wrong

  • @gabrielmsampson
    @gabrielmsampson 8 หลายเดือนก่อน

    What theme is this?

  • @0xcoder542
    @0xcoder542 2 ปีที่แล้ว

    @TutorialEdge - Thank you for creating such a nice tutorial video about GRPC. I found one issue while following the video. The "option go_package" missing in the Proto file? Please advise

  • @kirayamato6128
    @kirayamato6128 ปีที่แล้ว

    im new to go. what is the meaning of %v? ty in advance

  • @nikta456
    @nikta456 4 ปีที่แล้ว +2

    Getting a `Missing 'go_package' option in "chat.proto` after running a `protoc --go_out=plugins=grpc:chat chat.proto` (Win 10). Any suggestions?

    • @nikta456
      @nikta456 4 ปีที่แล้ว +1

      Was able to fix it by adding `option go_package = "github.com/monkrus/grpc-from0;grpc_from0";` line. Walkthrough of this great tutorial is here github.com/monkrus/grpc-from0

  • @sanjanaprakash1648
    @sanjanaprakash1648 4 ปีที่แล้ว +4

    Thank you for the video, very useful. One doubt, server.go and client.go both have main functions and they are in the same package. How does this work? Sorry I'm a newbie to Golang, so don't know much. It'll be great if anyone could clear the doubt.

    • @georgelza
      @georgelza 3 ปีที่แล้ว +2

      if you execute go run . then you would have a problem, but as you're executing go run server.go it only looks internal to that file, it's not aware of the main package in client.go

  • @seoch2064
    @seoch2064 4 ปีที่แล้ว +1

    When generating chat.pb.go, my file is different from the one the video shows. For instance, I don't have the Marshall and Unmarshall functions, what could be causing this?

    • @rinosukmandityo6448
      @rinosukmandityo6448 4 ปีที่แล้ว

      I think that because different version of protoc or protoc-gen-go. And that should not cause a problem IMO.

  • @bulsyt9903
    @bulsyt9903 2 ปีที่แล้ว

    Nice video 🔥 can golang grpc use a different package between server and client?

  • @prasannadiwadkar8153
    @prasannadiwadkar8153 4 ปีที่แล้ว +2

    chat.pb.go. How should i import this in another go file ?

    • @milakay
      @milakay 4 ปีที่แล้ว

      Add the following to your import statement in client.go and server.go:
      "./chat"

  • @palashbhasme3900
    @palashbhasme3900 2 หลายเดือนก่อน

    it gives main redeclared in error

  • @umeshsunnapu
    @umeshsunnapu 2 ปีที่แล้ว

    very helpful. just one edit compared to when this is recorded vs current releases of protoc, proto-gen-go-grpc etc. I believe
    executing protoc command, did not add package name in chat.pb.go and instead had it like ___. Change that to "chat"

  • @anilchaudhry804
    @anilchaudhry804 3 ปีที่แล้ว +1

    can you please come up with some real world microservice using golang? It helps a lot especially for young developers. Lets build from scratch??

    • @Tutorialedge
      @Tutorialedge  3 ปีที่แล้ว

      This is a great idea and something I will be doing on my site in the form of a course! I've got a couple of real-world examples I want to solve myself, so building courses around these adventures would be great :)

  • @vtvvnha2230
    @vtvvnha2230 4 ปีที่แล้ว +2

    thank you

  • @codelucky
    @codelucky 4 ปีที่แล้ว +3

    gRPC vs GraphQL ? With Go.

    • @Tutorialedge
      @Tutorialedge  4 ปีที่แล้ว +1

      Thanks for the suggestion! I'm not sure I could do a direct comparison on these two technologies though as they approach 2 different problem domains.
      In fact, I believe they could be used together, where a GraphQL application talks to a gRPC server in order to retrieve some of the data!

    • @codelucky
      @codelucky 4 ปีที่แล้ว +1

      @@Tutorialedge There are not many courses available on gRPC with Go. I wonder why? Is it because of its low popularity or due to any technical reason? Or is it difficult to implement than GraphQL?

    • @Zapanath
      @Zapanath 4 ปีที่แล้ว

      LucKie they have different use cases...

    • @jayeshthamke7860
      @jayeshthamke7860 4 ปีที่แล้ว

      @@codelucky Though there are less tutorial doesn't mean gRPC is less popular or has no usecase. In Kubernetes, they use gRPC to communicate and data transfer within cluster

  • @abbyck
    @abbyck 4 ปีที่แล้ว +3

    Thanks

  • @srikantprasad6711
    @srikantprasad6711 4 ปีที่แล้ว +3

    Thanks for this video. Sir if you want to create a tutorial. Please create tutorial on gomobile.
    How to create mobile app in golang.

  • @BrackenDawson
    @BrackenDawson 2 ปีที่แล้ว

    context has been in the standard library for a long time..

  • @AndiSyafrianda
    @AndiSyafrianda 4 ปีที่แล้ว +2

    jejak gans

  • @tnvmadhav2442
    @tnvmadhav2442 4 ปีที่แล้ว +1

    👏🏻

  • @NancyLopez-g8n
    @NancyLopez-g8n 2 หลายเดือนก่อน

    Sheila Knoll

  • @creddym1
    @creddym1 3 ปีที่แล้ว +1

    super youtube why beacuse he put in youtube vidio thanks all youtube

  • @ElizabethPerez-t8w
    @ElizabethPerez-t8w 3 หลายเดือนก่อน

    Josephine Lodge

  • @benwatson9633
    @benwatson9633 10 หลายเดือนก่อน

    thank you 2x speed

    • @Tutorialedge
      @Tutorialedge  10 หลายเดือนก่อน

      Most people struggle with my Scottish accent so I do find myself slowing down when recording 😂

  • @abdulrahmanmohmmd1029
    @abdulrahmanmohmmd1029 ปีที่แล้ว +1

    For those who having error in the new version with generation thr grpc files
    Run
    protoc -proto_path=. *.proto -go_out=. -go-grpc_out=.

    • @ExiNani
      @ExiNani ปีที่แล้ว

      help a lot

  • @Suriprofz
    @Suriprofz ปีที่แล้ว

    grpc is undefined

  • @bharathram3977
    @bharathram3977 16 วันที่ผ่านมา

    How is this even a good tutorial? He is typing out lines and lines of code without explaining how everything ties together. Commenters are either wayyy too smart or they are bots

  • @hackaholic01
    @hackaholic01 10 หลายเดือนก่อน

    sorry Man, but I have to say grpc are shiny and fancy words, TCP is simple and more efficient than grpc

    • @Tutorialedge
      @Tutorialedge  10 หลายเดือนก่อน

      gRPC is typically built on-top of TCP and is one of the highest performance methods of transportation available due to the fact you are sending far smaller amounts of information (typically) than say JSON over HTTP.
      In terms of simplicity, I’d 100% agree with the statement that JSON over HTTP wins every day of the week. I’ve seen both sides of the coin and definitely lean more towards JSON over HTTP for all applications that don’t demand the absolute highest of performance.

  • @sammyj29
    @sammyj29 3 หลายเดือนก่อน

    My chat.pb.go doesn't have the RegisterChatServiceServer function for some reason. Am I doing something wrong?

  • @RalphTruman-e4s
    @RalphTruman-e4s 3 หลายเดือนก่อน

    6537 Fred Passage

  • @creddym1
    @creddym1 3 ปีที่แล้ว +1

    This was a very useful tutorial thank you 👌! I would be grateful if you could you show us stream examples and maybe connecting it to MongoDB with how to bind them to primitives using todos as an example would be awesome!