Skip to content

Commit

Permalink
refactor: update gen-proto.sh for go 1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer committed Mar 19, 2022
1 parent a37ca10 commit fe0c82a
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 44 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,45 @@ jobs:
- name: test
run: go test -v ./...

test_build_proto:
strategy:
matrix:
go-version:
- 1.14.x
- 1.15.x
- 1.16.x
- 1.17.x
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

- name: checkout
uses: actions/checkout@v2

- name: cache
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: |
./install-protoc.sh
# mac issue: need to add execute privilege
chmod +x bin/protoc
echo "$PWD/bin" >> $GITHUB_PATH
- run: |
go get github.com/gogo/protobuf/protoc-gen-gogofaster@v1.3.2
- run: |
go env GOPATH
export GOPATH=$(go env GOPATH)
echo "GOPATH: ($GOPATH)"
./gen-proto.sh
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- go: tip
install:
- ./install-protoc.sh
- go get github.com/golang/protobuf/protoc-gen-go
- go get github.com/gogo/protobuf/protoc-gen-gogofaster@v1.3.2
script:
- make gen
- ./gen-proto.sh
- go test ./...
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
gen:
# go get github.com/golang/protobuf/{proto,protoc-gen-go}@v1.2.0
protoc --proto_path=proto --go_out=plugins=grpc:paxoskv paxoskv.proto
./gen-proto.sh
5 changes: 3 additions & 2 deletions gen-proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
# go get github.com/gogo/protobuf/protoc-gen-gogofaster
# go get github.com/gogo/protobuf/protoc-gen-gogoslick

echo "GOPATH: ($GOPATH)"

protoc -I=. \
-I=$GOPATH/src \
-I=$GOPATH/src/github.com/gogo/protobuf/protobuf \
-I=$GOPATH/pkg/mod/github.com/gogo/protobuf@v1.3.2 \
--proto_path=proto \
--gogofaster_out=plugins=grpc:paxoskv \
paxoskv.proto
73 changes: 36 additions & 37 deletions paxoskv/paxoskv.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion proto/paxoskv.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ syntax = "proto3";
package paxoskv;
option go_package = ".;paxoskv";

import "github.com/gogo/protobuf/gogoproto/gogo.proto";
// Go Modules now includes the version in the filepath for packages within GOPATH/pkg/mode
// Therefore unless we want to hardcode a version here like
// github.com/gogo/protobuf@v1.3.0/gogoproto/gogo.proto then the only other choice is to
// have a more relative import and pass the right import path to protoc. I don't like it
// but its necessary.
import "gogoproto/gogo.proto";

option (gogoproto.equal_all) = true;
option (gogoproto.compare_all) = true;
Expand Down

0 comments on commit fe0c82a

Please sign in to comment.