[gRPC #9.1] Serialize protobuf message - Golang

Поделиться
HTML-код
  • Опубликовано: 2 дек 2024

Комментарии • 26

  • @apoorvamishra5952
    @apoorvamishra5952 3 года назад +3

    Awesome Content , thanks for that :) I think if you are in same package you don't need to import it in test files, rather just use the name of the function given the name of the function starts with caps.

  • @rodrigodonizettideoliveira6102
    @rodrigodonizettideoliveira6102 3 года назад +9

    I was facing the following issue: "cannot use message (type protoreflect.ProtoMessage) as type protoiface.MessageV1 in argument to marshaler.MarshalToString".
    I guess it was due to version mismatching.
    Pay attention to the imports and change the ProtobufToJson function to:
    import (
    "google.golang.org/protobuf/encoding/protojson"
    "google.golang.org/protobuf/proto"
    )
    func ProtobufToJson(message proto.Message) (string, error) {
    marshaler := protojson.MarshalOptions{
    UseEnumNumbers: false,
    EmitUnpopulated: true,
    Indent: " ",
    UseProtoNames: true,
    }
    data, err := marshaler.Marshal(message)
    return string(data), err
    }
    github.com/golang/protobuf/issues/1133
    Thank you very much for sharing your knowledge with us!

    • @TECHSCHOOLGURU
      @TECHSCHOOLGURU  3 года назад +2

      Thanks Rodrigo. Indeed there might be some differences in the generated code if you use different versions of protobuf.

  • @johnnychang3456
    @johnnychang3456 2 года назад

    This is high quality Go code. Thank you!

  • @SriRam-fk9fq
    @SriRam-fk9fq 3 года назад +1

    One of the best resources for gRPC! I purchased this course on Udemy as well. Do you have any plans to expand your tutorials, especially the Go programming language itself? If so, that would be great!

    • @TECHSCHOOLGURU
      @TECHSCHOOLGURU  3 года назад

      Thanks so much, Sri! You can find more tutorials in our youtube channel: ruclips.net/user/TECHSCHOOLGURU
      This is the backend master course with Golang: ruclips.net/p/PLy_6D98if3ULEtXtNSY_2qN21VCKgoQAE

  • @Marlem80
    @Marlem80 2 года назад

    I guess jsonpb is deprecated, right? I used protojson instead...

  • @ArjunTiwari91
    @ArjunTiwari91 3 года назад

    I am getting access denied error while running go test ./... maybe because I dont have permisiion to change the file

  • @tlgki
    @tlgki 3 года назад

    e thấy a có viết func xong nó tự điền import đó ạ, không biết nó là extention gì e tìm không thấy a.

    • @TECHSCHOOLGURU
      @TECHSCHOOLGURU  3 года назад

      Hi Kiên,
      Anh thấy chỉ cần cài golang plugin của vscode, sau đó nó sẽ install một số package của go để có tự động import & auto complete.
      Em có thể xem video này cho rõ hơn: ruclips.net/video/jRLV-1GVET4/видео.html

  • @AbhishekVaid
    @AbhishekVaid 3 года назад

    In Json serialization we have value (uint64) serialized as string. Why is that the case ?

    •  4 месяца назад

      A bit late, however if somebody is interested in the answer. Interoperability as defined by rfc7159. Although technically JSON has no precision limits on numbers, JavaScript and other languages do: 2^53. Unfortunately unit64 falls outside of that range.

  • @nhattrungvodai2525
    @nhattrungvodai2525 2 года назад

    Great Content . Thank you so much !

  • @idirdev3729
    @idirdev3729 4 года назад

    Thanks for these great resources.

  • @magnifico689
    @magnifico689 5 лет назад

    Can you also do with nodejs.

    • @TECHSCHOOLGURU
      @TECHSCHOOLGURU  5 лет назад +1

      Thanks Jerry for the suggestion. However, it's not in the scope of this course at the moment. I believe doing this for NodeJS would be very similar to Go or Java.

  • @MarekCzechyra
    @MarekCzechyra 4 года назад

    Does anybody else have problem with donwload and clone sources from repo on GitLab?
    I still get message from browser: 429 Too many requests received, and for git from commnd line:
    git clone git@gitlab.com:techschool/pcbook.git
    Cloning into 'pcbook'...
    git@gitlab.com: Permission denied (publickey).
    fatal: Could not read from remote repository.
    Please make sure you have the correct access rights
    and the repository exists.

    • @TECHSCHOOLGURU
      @TECHSCHOOLGURU  4 года назад

      Hi Marek, if you haven't set up SSH key for your gitlab account, you should clone by HTTPS instead:
      git clone gitlab.com/techschool/pcbook.git

  • @nossandra
    @nossandra 4 года назад

    Thank you very much!

  • @AbhishekVaid
    @AbhishekVaid 4 года назад

    Hey how do I find you on linkedin ?

    • @TECHSCHOOLGURU
      @TECHSCHOOLGURU  4 года назад

      Hi Abhishek, you can find Tech School on Linkedin at this link: www.linkedin.com/company/34649008/admin/