Coder Social home page Coder Social logo

buf_playground's Introduction

Buf.build Playgroud

intro

buf.build可以替代protoc进行更工程化的proto管理

安装

# 下载 "https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-$(uname -s)-$(uname -m)"
BIN="/usr/local/bin" && \
sudo mv buf-Linux-x86_64 "${BIN}/buf" \
chmod +x "${BIN}/buf"

使用

初始化

# 初始化一个新的 Buf 项目
buf init

这将创建一个新的 buf.yaml 文件,该文件包含了 Buf 的配置信息。 buf.yaml里面应该包含有我们项目中需要使用的依赖。

定义proto

Buf 使用 Protobuf 文件(.proto 文件)作为输入,因此你需要创建一个或多个 Protobuf 文件来定义你的 API。例如,你可以创建一个名为 user.proto 的文件,并在其中定义一个简单的 gRPC 服务:

配置buf

接下来,你需要配置 Buf 以编译你的 Protobuf 文件。在你的项目根目录下创建一个名为 buf.gen.yaml 的文件,这里定义了如何编译你的proto文件

编译

现在,你可以使用以下命令编译你的 Protobuf 文件:

# 编译 Protobuf 文件
buf generate

buf_playground's People

Contributors

wangx0111 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.