-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
56 lines (46 loc) · 1.71 KB
/
Makefile
File metadata and controls
56 lines (46 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
.PHONY: proto test build clean example
# Generate protobuf code
# Note: go/proto/message.pb.go is checked into version control
# Only regenerate if you modify proto/message.proto
proto:
@echo "Generating protobuf code to go/proto/..."
protoc --go_out=go/proto --go_opt=paths=source_relative --proto_path=proto/ proto/*.proto
# Generate example proto
# Note: go/examples/userservice/proto/user.pb.go is also checked in
proto-example:
@echo "Generating example protobuf code to go/examples/userservice/proto/..."
protoc \
--go_out=go/examples/userservice/proto --go_opt=paths=source_relative \
--go-grpc_out=go/examples/userservice/proto --go-grpc_opt=paths=source_relative \
--proto_path=go/examples/userservice go/examples/userservice/user.proto
# Run all tests
test:
cd go && go test --race -v ./...
# Build the example
example:
go build -o bin/userservice-example ./go/examples/userservice
# Run the example
run-example: example
./bin/userservice-example
# Clean generated files (keeps checked-in proto packages)
clean:
rm -rf bin/
find . -name "*.pb.go" ! -path "./go/proto/*" ! -path "./go/examples/*/proto/*" -delete
# Format code
fmt:
go fmt ./...
# Run linter
lint:
golangci-lint run ./...
# Help
help:
@echo "Available targets:"
@echo " proto - Generate protobuf code from proto files"
@echo " proto-example - Generate example protobuf code"
@echo " test - Run all tests"
@echo " example - Build the example service"
@echo " run-example - Build and run the example service"
@echo " clean - Remove generated files and binaries"
@echo " fmt - Format Go code"
@echo " lint - Run linter"
@echo " help - Show this help message"