Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add a guide on generating golang code using buf #50

Merged
merged 1 commit into from
Oct 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Following are the considerations for going with single repository:
- This repository contains protocol buffers that have common patterns and APIs that services can reuse instead of spending effort in writing these protobufs. Each subdirectory contains details of the respective protos.
- Validation, generation, and other proto-related operations can be placed in one place. Thus, avoid duplication.
- We also see good possibility to reuse proto schema. Have it in one place make it easy to import proto.

## Usage
Proton does not provide compiled language specific proto files or the descriptor sets for the respective protos. It is upto the users to pull these protos and use `protoc` for language specific compiled files and have dependencies/imports in their code.

Expand All @@ -15,6 +16,33 @@ Proton does not provide compiled language specific proto files or the descriptor
## Structure
Proton has flat structure where proto files are put under /odpf/proton/\<application\>/. Each application's sub directory read me provides details on how to use the respective proto.

## Guide

### Generating go code using buf

***This guide is last tried on buf version `1.0.0-rc4`.***

Add this `buf.gen.yaml` at the root folder.

```
version: v1beta1
plugins:
- name: go
out: dst
opt: paths=source_relative
```

Run below command to generate your proto to `/dst` folder.

```
buf generate
```

Use below command if you just want to target specific package/folder
```
buf generate --path odpf/assets
```

## Contribute
Prerequisite: You need to have [buf](https://buf.build/) installed

Expand Down