安装:
# git clone https://github.com/grpc/grpc-go.git $GOPATH/pkg/mod/google.golang.org/grpc
# git clone https://github.com/golang/net.git $GOPATH/pkg/mod/golang.org/x/net
git clone https://github.com/golang/text.git /$GOPATH/pkg/mod/golang.org/x/text
go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
git clone https://github.com/google/go-genproto.git $GOPATH/pkg/mod/google.golang.org/genprotoprotoc \-I . \-I ${GOPATH}/src \-I ${GOPATH}/src/github.com/envoyproxy/protoc-gen-validate \--go_out=plugins=grpc:../../pb/pb_test/ \--validate_out="lang=go:../../pb/pb_test/" \test.proto

命令用法:

protoc -h       
Usage: protoc [OPTION] PROTO_FILES
Parse PROTO_FILES and generate output based on the options given:
  -IPATH, --proto_path=PATH   Specify the directory in which to search for
                              imports.  May be specified multiple times;
                              directories will be searched in order.  If not
                              given, the current working directory is used.
                              If not found in any of the these directories,
                              the --descriptor_set_in descriptors will be
                              checked for required proto file.
  --version                   Show version info and exit.
  -h, --help                  Show this text and exit.
  --encode=MESSAGE_TYPE       Read a text-format message of the given type
                              from standard input and write it in binary
                              to standard output.  The message type must
                              be defined in PROTO_FILES or their imports.
  --decode=MESSAGE_TYPE       Read a binary message of the given type from
                              standard input and write it in text format
                              to standard output.  The message type must
                              be defined in PROTO_FILES or their imports.
  --decode_raw                Read an arbitrary protocol message from
                              standard input and write the raw tag/value
                              pairs in text format to standard output.  No
                              PROTO_FILES should be given when using this
                              flag.
  --descriptor_set_in=FILES   Specifies a delimited list of FILES
                              each containing a FileDescriptorSet (a
                              protocol buffer defined in descriptor.proto).
                              The FileDescriptor for each of the PROTO_FILES
                              provided will be loaded from these
                              FileDescriptorSets. If a FileDescriptor
                              appears multiple times, the first occurrence
                              will be used.
  -oFILE,                     Writes a FileDescriptorSet (a protocol buffer,
    --descriptor_set_out=FILE defined in descriptor.proto) containing all of
                              the input files to FILE.
  --include_imports           When using --descriptor_set_out, also include
                              all dependencies of the input files in the
                              set, so that the set is self-contained.
  --include_source_info       When using --descriptor_set_out, do not strip
                              SourceCodeInfo from the FileDescriptorProto.
                              This results in vastly larger descriptors that
                              include information about the original
                              location of each decl in the source file as
                              well as surrounding comments.
  --dependency_out=FILE       Write a dependency output file in the format
                              expected by make. This writes the transitive
                              set of input file paths to FILE
  --error_format=FORMAT       Set the format in which to print errors.
                              FORMAT may be 'gcc' (the default) or 'msvs'
                              (Microsoft Visual Studio format).
  --print_free_field_numbers  Print the free field numbers of the messages
                              defined in the given proto files. Groups share
                              the same field number space with the parent 
                              message. Extension ranges are counted as 
                              occupied fields numbers.

--plugin=EXECUTABLE         Specifies a plugin executable to use.
                              Normally, protoc searches the PATH for
                              plugins, but you may specify additional
                              executables not in the path using this flag.
                              Additionally, EXECUTABLE may be of the form
                              NAME=PATH, in which case the given plugin name
                              is mapped to the given executable even if
                              the executable's own name differs.
  --cpp_out=OUT_DIR           Generate C++ header and source.
  --csharp_out=OUT_DIR        Generate C# source file.
  --java_out=OUT_DIR          Generate Java source file.
  --js_out=OUT_DIR            Generate JavaScript source.
  --objc_out=OUT_DIR          Generate Objective C header and source.
  --php_out=OUT_DIR           Generate PHP source file.
  --python_out=OUT_DIR        Generate Python source file.
  --ruby_out=OUT_DIR          Generate Ruby source file.
  @<filename>                 Read options and filenames from file. If a
                              relative file path is specified, the file
                              will be searched in the working directory.
                              The --proto_path option will not affect how
                              this argument file is searched. Content of
                              the file will be expanded in the position of
                              @<filename> as in the argument list. Note
                              that shell expansion is not applied to the
                              content of the file (i.e., you cannot use
                              quotes, wildcards, escapes, commands, etc.).
                              Each line corresponds to a single argument,
                              even if it contains spaces.

Go语言grpc proto生成pb文件相关推荐

  1. 【tensorflow】生成.pb文件

    Saving, Freezing, Optimizing for inference, Restoring of tensorflow models 在训练完tensorflow模型后,会有三个文件: ...

  2. go语言生成.proto生成go文件

    go下载插件到bin目录下, 使用go env 可以查看 go install google.golang.org/protobuf/cmd/protoc-gen-go@latest 可以直接使用了, ...

  3. mac golang grpc proto pb文件生成go文件.md

    文章目录 1.简介 2.操作步骤 1. 安装基础的protoc工具 1. 下载 2. 添加protoc到PATH 3. 安装golang的支持 4. 使用 1. 普通编译 2. import的路径 参 ...

  4. Slim生成的ckpt文件转PB文件

    前言 搭建Slim框架方法请参考这篇文章:搭建迁移训练Slim框架环境_17岁boy的博客-CSDN博客 生成PB文件 转换的方式也很简单,Slim自带了一个graph.py文件,文件存在于model ...

  5. TensorFlow:将ckpt文件固化成pb文件

    TensorFlow:将ckpt文件固化成pb文件 本文是将yolo3目标检测框架训练出来的ckpt文件固化成pb文件,主要利用了GitHub上的该项目. 为什么要最终生成pb文件呢?简单来说就是直接 ...

  6. 小白Bert系列-生成pb模型,tfserving加载,flask进行预测

    bert分类模型使用tfserving部署. bert模型服务化现在已经有对应开源库部署. 例如:1.https://github.com/macanv/BERT-BiLSTM-CRF-NER 该项目 ...

  7. tensorflow之pb文件保存与载入

    pb是protocol(协议) buffer(缓冲)的缩写.TensorFlow训练模型后存成的pb文件,是一种表示模型(神经网络)结构的二进制文件,将图中的变量保存成为常量,便于调用,一般无法将pb ...

  8. 深度学习(六)——CNN识别典型地标建筑,并制作pb文件,部署在android studio端,制作app实现该功能

    一.背景 两年前的一个项目,识别典型地标,并对图片进行标记.这里只写一下简单思路,最开始是打算用特征点匹配来做的,可以参考:基于特征点匹配方法--SIFT, SURF, ORB的图像识别 ,后来发现效 ...

  9. pb文件生成java类,根据proto文件生成pb和pb_service文件

    假如有一个HelloWorld.proto文件,内容如下: syntax = "proto3"; option java_package = "ex.grpc" ...

  10. 根据proto文件生成pb和pb_service文件

    假如有一个HelloWorld.proto文件,内容如下: syntax = "proto3";option java_package = "ex.grpc"; ...

最新文章

  1. GPT-4前奏?OpenAI发布120亿参数图像版GPT-3
  2. HTML中各种位置距离关系
  3. 试试博客园的markdown编辑器
  4. 用计算机控制人造卫星和导弹的发射属于,2008年6月全国高校计算机等级考试(广西考区)一级笔试试题卷...
  5. C++设计模式--代理模式(Proxy)
  6. [js] 说说你对JS中暂性死区的理解,它有什么运用场景?
  7. LeetCode 97. 交错字符串(DP)
  8. JAVA WEB篇4——Filter、Listener
  9. Vertx JDBC 批处理
  10. Mybatis学习IDEA(1)-环境搭建以及入门案例
  11. JAVA判断输入日期是否合法
  12. 如何使用CleanMyMac彻底擦除文件?
  13. Android 学习资料
  14. IP子网划分的原理及应用
  15. 禁用win10触摸屏手势_怎么修改win10 触控板手势设置
  16. 使用python 批量修改图片分辨率
  17. 利用CSS调整图片大小
  18. 修改变量名,简单有效地提高代码质量!
  19. js获取父元素、子元素、兄弟元素的方法
  20. 道家养生的最高境界-天人合一

热门文章

  1. mindoc mysql_MinDoc 配置文件详解
  2. 操作系统实验Lab 2:system calls(MIT 6.S081 FALL 2020)
  3. Comsol Multiphysics安装步骤详解
  4. 浙大翁凯老师Java课堂学习记录(第二周)
  5. 极点五笔特殊符号输入方法
  6. 这一份Spring源码解析PDF,阿里架构师直言:全网最深度解析!
  7. petalinux 建立工程两种方式
  8. 日照分析的计算机精度,日照分析计算精度(时间间隔)的粗探
  9. 小程序倒计时,已知过期时间实现倒计时
  10. MySQL 8.0.19安装教程(windows 64位)