{"id":19989785,"url":"https://github.com/wcygan/buf-polyglot-example","last_synced_at":"2026-04-10T02:14:41.869Z","repository":{"id":217070737,"uuid":"743017456","full_name":"wcygan/buf-polyglot-example","owner":"wcygan","description":"Shows how to share Protobuf schemas across projects in different languages","archived":false,"fork":false,"pushed_at":"2024-01-23T03:09:28.000Z","size":1772,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-01T21:52:39.969Z","etag":null,"topics":["buf","go","grpc","java","monorepo","protobuf","rust"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wcygan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-14T03:50:37.000Z","updated_at":"2024-01-16T03:53:29.000Z","dependencies_parsed_at":"2024-01-14T11:41:02.175Z","dependency_job_id":"dbba5ea8-6d8e-4340-98a4-4478f834665b","html_url":"https://github.com/wcygan/buf-polyglot-example","commit_stats":null,"previous_names":["wcygan/buf-polyglot-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wcygan/buf-polyglot-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wcygan%2Fbuf-polyglot-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wcygan%2Fbuf-polyglot-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wcygan%2Fbuf-polyglot-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wcygan%2Fbuf-polyglot-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wcygan","download_url":"https://codeload.github.com/wcygan/buf-polyglot-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wcygan%2Fbuf-polyglot-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286079811,"owners_count":27282121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-27T02:00:05.795Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["buf","go","grpc","java","monorepo","protobuf","rust"],"created_at":"2024-11-13T04:50:12.182Z","updated_at":"2025-11-27T02:04:19.716Z","avatar_url":"https://github.com/wcygan.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# buf-polyglot-example\n\nThis is an example of how to use [buf](https://buf.build/) in a multi-language repository.\n\n## Generate stubs from protobuf schemas\n\nRun the following command:\n\n```bash\n$ buf generate proto\n```\n\n## Start the server\n\nRun the following command:\n\n```bash\ncd go-server \u0026\u0026 go run .\n```\n\n## Testing with grpcurl\n\nYou can use [grpcurl](https://github.com/fullstorydev/grpcurl) to test the server:\n\n#### Request\n\n```bash\ngrpcurl -plaintext -proto proto/hello/v1/hello.proto -d '{\"name\": \"YourName\"}' localhost:50051 hello.v1.HelloService/SayHello\n```\n\n#### Response\n\n```json\n{\n  \"message\": \"Hello YourName\"\n}\n```\n\n## How did I get the [buf.yaml](proto/buf.yaml) file?\n\nI ran the following command in the [proto](proto) directory:\n\n```bash\n$ buf mod init\n```\n\n## How did I get the [buf.gen.yaml](buf.gen.yaml) file?\n\nI created it, then I added package names as well as plugins for the languages which I wanted to generate protobuf and\ngrpc stubs for.\n\n## How did I get IntelliJ to index the Java Subproject?\n\nI open the *root directory* of this project in IntelliJ and use the Go plugin. However, IntelliJ doesn't necessarily\nindex the subprojects properly.\n\n| Before                                        | During                                 | After                                        |\n|-----------------------------------------------|----------------------------------------|----------------------------------------------|\n| \u003cimg src=\"resources/before-mark-sources.png\"\u003e | \u003cimg src=\"resources/mark-sources.png\"\u003e | \u003cimg src=\"resources/after-mark-sources.png\"\u003e |\n\n## What are the [proto](proto) and `generated` folders for?\n\n### [proto](proto)\n\nThis folder contains the schemas that will be shared between clients and servers.\n\nYou define your schemas as [Protocol Buffers](https://protobuf.dev/) and then compile them into code for the languages\nyou want to use.\n\n[Buf](https://buf.build/) is used to compile the schemas into code. If you don't want to use buf, you can\nuse [protoc](https://grpc.io/docs/protoc-installation/) directly.\n\n### `generated`\n\nThis folder contains the generated code for the languages you want to use. The [buf.gen.yaml](buf.gen.yaml) file\ndefines which languages you want to generate code for.\n\n#### Java Integration\n\nTo integrate the Java code into the [java-client](java-client) project, I specified the [generated/java](generated/java)\nas a [SourceSet](https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/SourceSet.html)\nin [build.gradle](java-client/app/build.gradle).\nI also needed to make sure that the [generated](generated) folder was marked as a source folder in IntelliJ for proper\nindexing. Lastly, I needed to make sure that the version of protoc-gen-grpc-java:1.61.0 was the same\nin [buf.gen.yaml](buf.gen.yaml) and [build.gradle](java-client/app/build.gradle).\n\n#### Go Integration\n\nTo integrate the Go code into the [go-server](go-server) project, I created [generated/go.mod](generated/go.mod) and use\nit as a dependency in [go-server/go.mod](go-server/go.mod). This effectively pulls in the Go code as a dependency.\n\n#### Rust Integration\n\nThis was a PITA to figure out, but luckily https://github.com/neoeinstein/protoc-gen-prost exists and comes with the\noption to generate crates.\n\nUnfortunately, using the `gen_crate` option in [buf.gen.yaml](buf.gen.yaml) forces you to use the `prost-crate` plugin\nlocally, so you need to install it:\n\n```bash\ncargo install protoc-gen-prost-crate\n```\n\nIt was also unclear how to use this, but I found\na [tutorial](https://dev.to/martinp/roll-your-own-auth-with-rust-and-protobuf-3f78) which used this, and then I\nunderstood that you need\nto have a [Cargo.toml](generated/rust/Cargo.toml) file in the directory which you want to generate the crate in.\n\nAfter all of this ceremony, `buf generate proto` worked as expected and I was able to plug the generated code\ninto [rust-client](rust-client)'s [Cargo.toml](rust-client/Cargo.toml) with local pathing.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwcygan%2Fbuf-polyglot-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwcygan%2Fbuf-polyglot-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwcygan%2Fbuf-polyglot-example/lists"}