Skip to content
This repository was archived by the owner on Feb 20, 2026. It is now read-only.
Open
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ name: Go

on:
push:
workflow_dispatch:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
Expand All @@ -13,7 +17,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version: 1.20

- name: Check out code into the Go module directory
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion COMPILE-PROTOS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
TMP_GOBIN=$(mktemp -d -t gnostic-grpc.XXXXXXXXXX)

GOBIN=${TMP_GOBIN} go install ./search
GOBIN=${TMP_GOBIN} go install -mod=mod github.com/golang/protobuf/protoc-gen-go@v1.5.2
GOBIN=${TMP_GOBIN} go install -mod=mod google.golang.org/protobuf/cmd/protoc-gen-go@v1.29.1
PATH="$TMP_GOBIN:$PATH" protoc --go_out=incompatibility/ ./incompatibility/incompatibility-report.proto

rm -rf "${TMP_GOBIN}"
14 changes: 7 additions & 7 deletions examples/end-to-end-grpc-gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ This tutorial has six steps:

#### Prerequisite
Install [gnostic](https://github.com/google/gnostic), [gnostic-grpc](https://github.com/google/gnostic-grpc),
[go plugin for protoc](https://github.com/golang/protobuf/protoc-gen-go), [gRPC gateway plugin](https://github.com/grpc-ecosystem/grpc-gateway)
[go plugin for protoc](https://github.com/protocolbuffers/protobuf-go/tree/master/cmd/protoc-gen-go), [gRPC gateway plugin](https://github.com/grpc-ecosystem/grpc-gateway)
and [gRPC](https://grpc.io/)

go get -u github.com/google/gnostic
go get -u github.com/google/gnostic@v0.6.9
go get -u github.com/google/gnostic-grpc
go get -u github.com/golang/protobuf/protoc-gen-go
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u google.golang.org/grpc
go get -u google.golang.org/protobuf/cmd/protoc-gen-go@v1.29.1
go get -u github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@v2.16.2
go get -u google.golang.org/grpc@v1.41.0

For simplicity lets create a temporary environment variable inside your terminal:

Expand All @@ -49,7 +49,7 @@ description (`bookstore.proto`) in the current directory:
#### 2. Step
Generate the gRPC stubs:

protoc --proto_path=. --proto_path=${ANNOTATIONS} --go_out=plugins=grpc:bookstore bookstore.proto
protoc --proto_path=. --proto_path=${ANNOTATIONS} --go_out=paths=source_relative:bookstore --go-grpc_out=paths=source_relative:bookstore bookstore.proto

This generates `bookstore/bookstore.pb.go`.

Expand All @@ -59,7 +59,7 @@ We added an example implementation of the server using the generated gRPC stubs
#### 4. Step
Generate the reverse proxy with the gRPC gateway plugin:

protoc --proto_path=. --proto_path=${ANNOTATIONS} --grpc-gateway_out=bookstore bookstore.proto
protoc --proto_path=. --proto_path=${ANNOTATIONS} --grpc-gateway_out=bookstore bookstore.proto

This generates `bookstore/bookstore.pb.gw.go`.

Expand Down
39 changes: 24 additions & 15 deletions examples/end-to-end-grpc-gateway/bookstore.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ package bookstore;

import "google/api/annotations.proto";

import "google/protobuf/descriptor.proto";

import "google/protobuf/empty.proto";

import "google/protobuf/descriptor.proto";
option go_package = ".;bookstore";

message Book {
string author = 1;
Expand Down Expand Up @@ -36,35 +38,42 @@ message Error {
string message = 2;
}

message CreateShelfParameters {
//CreateShelfParameters holds parameters to CreateShelf
message CreateShelfRequest {
Shelf shelf = 1;
}

message GetShelfParameters {
//GetShelfParameters holds parameters to GetShelf
message GetShelfRequest {
int64 shelf = 1;
}

message DeleteShelfParameters {
//DeleteShelfParameters holds parameters to DeleteShelf
message DeleteShelfRequest {
int64 shelf = 1;
}

message ListBooksParameters {
//ListBooksParameters holds parameters to ListBooks
message ListBooksRequest {
int64 shelf = 1;
}

message CreateBookParameters {
//CreateBookParameters holds parameters to CreateBook
message CreateBookRequest {
int64 shelf = 1;

Book book = 2;
}

message GetBookParameters {
//GetBookParameters holds parameters to GetBook
message GetBookRequest {
int64 shelf = 1;

int64 book = 2;
}

message DeleteBookParameters {
//DeleteBookParameters holds parameters to DeleteBook
message DeleteBookRequest {
int64 shelf = 1;

int64 book = 2;
Expand All @@ -75,35 +84,35 @@ service Bookstore {
option (google.api.http) = { get:"/shelves" };
}

rpc CreateShelf ( CreateShelfParameters ) returns ( Shelf ) {
rpc CreateShelf ( CreateShelfRequest ) returns ( Shelf ) {
option (google.api.http) = { post:"/shelves" body:"shelf" };
}

rpc DeleteShelves ( google.protobuf.Empty ) returns ( google.protobuf.Empty ) {
option (google.api.http) = { delete:"/shelves" };
}

rpc GetShelf ( GetShelfParameters ) returns ( Shelf ) {
rpc GetShelf ( GetShelfRequest ) returns ( Shelf ) {
option (google.api.http) = { get:"/shelves/{shelf}" };
}

rpc DeleteShelf ( DeleteShelfParameters ) returns ( google.protobuf.Empty ) {
rpc DeleteShelf ( DeleteShelfRequest ) returns ( google.protobuf.Empty ) {
option (google.api.http) = { delete:"/shelves/{shelf}" };
}

rpc ListBooks ( ListBooksParameters ) returns ( ListBooksResponse ) {
rpc ListBooks ( ListBooksRequest ) returns ( ListBooksResponse ) {
option (google.api.http) = { get:"/shelves/{shelf}/books" };
}

rpc CreateBook ( CreateBookParameters ) returns ( Book ) {
rpc CreateBook ( CreateBookRequest ) returns ( Book ) {
option (google.api.http) = { post:"/shelves/{shelf}/books" body:"book" };
}

rpc GetBook ( GetBookParameters ) returns ( Book ) {
rpc GetBook ( GetBookRequest ) returns ( Book ) {
option (google.api.http) = { get:"/shelves/{shelf}/books/{book}" };
}

rpc DeleteBook ( DeleteBookParameters ) returns ( google.protobuf.Empty ) {
rpc DeleteBook ( DeleteBookRequest ) returns ( google.protobuf.Empty ) {
option (google.api.http) = { delete:"/shelves/{shelf}/books/{book}" };
}
}
Expand Down
Loading