douhongxie5436 2019-04-22 02:15 采纳率: 100%
浏览 38
已采纳

如何从该站点下载协议缓冲区v3?

I'm following this tutorial to install Protocol Buffers v3:

https://grpc.io/docs/quickstart/go.html#install-grpc

It says "The simplest way to do this is to download pre-compiled binaries for your platform", what is "platform" here? Operating System or Programming Languages? Im confused at this step, because I dont understand what its saying exactly.

I even tried to follow the link but there is no Protobuf installation for "GoLang" at all, I can see java, python, linux, win, osx etc and I dont know which one to choose and this added to my frustration:

http://prntscr.com/nf2qye

Even if I download the file somehow then how and exactly where do I unzip in Linux?

Even if I unzip it somewhere then what will be the code to write in the bash_profile to update the environment variable PATH to include the path to the protoc binary file as mentioned in the tutorial?

Please help, thanks.

  • 写回答

1条回答 默认 最新

  • dqgxazo4483 2019-04-22 03:29
    关注

    that binary is OS dependent and contains the protoc compiler to compile the protobuffs.

    protoc-3.6.0-linux-x86_64.zip

    Note: 3.6.0 is not the latest version

    you will find all the binary here

    download the zip, unzip and copy that protoc bin to

    /usr/local/bin
    

    run below commands for Linux:

    mkdir -p /tmp/protoc && \
            wget https://github.com/google/protobuf/releases/download/v3.6.0/protoc-3.6.0-linux-x86_64.zip && \
            unzip protoc-3.6.0-linux-x86_64.zip -d protoc3 && \
            cp protoc3/bin/* /usr/local/bin/ && \
            cp -R protoc3/include/* /usr/local/include && \
            chmod +x /usr/local/bin/protoc && \
            rm -rf /tmp/protoc 
    

    just type protoc in the terminal, it should work.

    For go lang code generation, you have to download code generator separately. i,e;

    protoc-gen-go.

    install go and set the GOPATH.

    then, run below command :

    go get github.com/golang/protobuf/protoc-gen-go
    

    After that, you could use go code generator plugin to generate the code like below:

    protoc -I . hello.proto --go_out=plugins=grpc:out
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?