Giter VIP home page Giter VIP logo

proto_build's Introduction

proto_build

摆脱繁琐编译命令,实现proto编译自由

准备:

确保你有完整的GRPC运行环境(protocprotoc-gen-goprotoc-gen-go-grpc),不完整的请自行安装,下面的安装方式可能有误,出现错误请查找网上教程

  • protoc下载最新protoc放入bin目录下
  • protoc-gen-gogo install google.golang.org/protobuf/cmd/[email protected](v0.0.3会自动下载)
  • protoc-gen-go-grpcgo install google.golang.org/grpc/cmd/[email protected](v0.0.3会自动下载)

使用:

  1. 源码运行:下载源码到项目中任意目录,运行main函数即可
  2. 命令行运行:下载源码编译或直接下载二进制包到项目文件,运行执行文件即可
  3. 自动运行:Goland自动编译proto文件

运行:

正确运行后命令行会提示:生成proto.go成功

根据proto文件会生成xxx.pb.goxxx_grpc.pb.go

image-20210927194226535

⚠️注意⚠️

因为proto文件导入其他proto文件,以及文件目录和包名等一系列组合原因,可能出现正确编译,但生成的go文件出现包引用错误,定义proto文件时,option go_packagego.mod中的名称加项目内相对路径,需要导入包import填入被导入包在项目内相对路径,举个栗子🌰:

option go_package = "proto_build/server/proto/file"; // proto_build为项目名称,server/proto/file为项目内相对路径
import "server/proto/cascade/cascade.proto"; // server/proto/cascade/cascade.proto 项目内相对路径

proto_build's People

Stargazers

唐墨夏 avatar 顾澜 avatar

Watchers

顾澜 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.