Skip to content

Commit 8ed72c7

Browse files
committed
fix: use tools package correctly to capture the versions
1 parent 19fb8ec commit 8ed72c7

File tree

6 files changed

+27
-15
lines changed

6 files changed

+27
-15
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
# Dependency directories (remove the comment below to include it)
1616
# vendor/
1717

18+
.idea/

Makefile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ ifeq ($(UNAME), Linux)
2020
export PATH="$${PATH}:$${HOME}/.local/bin"
2121
endif
2222
endif
23-
#ifeq ($(PROTOC_GEN_GO),)
24-
# (go mod download && grep _ ./cmd/tools.go | cut -d' ' -f2 | xargs go install)
25-
(go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest && go install google.golang.org/protobuf/cmd/protoc-gen-go@latest)
26-
#endif
27-
23+
ifeq ($(PROTOC_GEN_GO),)
24+
go mod download && grep _ ./cmd/tools/tools.go | cut -d' ' -f2 | xargs go install -v
25+
endif
26+
2827
all:
2928
mkdir -p ./pkg/pbs/
3029
protoc \
@@ -34,6 +33,6 @@ all:
3433
--go-grpc_out=. \
3534
--go-grpc_opt=paths=source_relative \
3635
$(PROTO_FILES)
37-
36+
3837
clean:
39-
rm -rf ./pkg/pbs/*.pb.go
38+
rm -rf ./pkg/pbs/*.pb.go

cmd/tools.go

Lines changed: 0 additions & 8 deletions
This file was deleted.

cmd/tools/tools.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// +build tools
2+
3+
// tools is a special package to capture the following packages into `go.mod`.
4+
//
5+
// These tools are used to generate Go files from Protocol Buffers.
6+
// But, these tools are not used directly in the code.
7+
// That's why we're capturing the packages in this file.
8+
//
9+
// Then, the following command will always install the same versions defined in `go.mod`.
10+
//
11+
// go install google.golang.org/grpc/cmd/protoc-gen-go-grpc google.golang.org/protobuf/cmd/protoc-gen-go
12+
package tools
13+
14+
import (
15+
_ "google.golang.org/grpc/cmd/protoc-gen-go-grpc"
16+
_ "google.golang.org/protobuf/cmd/protoc-gen-go"
17+
)

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ go 1.16
44

55
require (
66
google.golang.org/grpc v1.38.0
7+
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0
78
google.golang.org/protobuf v1.26.0
89
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQ
7070
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
7171
google.golang.org/grpc v1.38.0 h1:/9BgsAsa5nWe26HqOlvlgJnqBuktYOLCgjCPqsa56W0=
7272
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
73+
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 h1:M1YKkFIboKNieVO5DLUEVzQfGwJD30Nv2jfUgzb5UcE=
74+
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
7375
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
7476
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
7577
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=

0 commit comments

Comments
 (0)