Skip to content

Instantly share code, notes, and snippets.

@jxlwqq
Created October 12, 2021 02:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jxlwqq/db2e8fe10d3e87f172cef9866bda701f to your computer and use it in GitHub Desktop.
Save jxlwqq/db2e8fe10d3e87f172cef9866bda701f to your computer and use it in GitHub Desktop.
make proto
.PHONY: proto
proto:
@ if ! which protoc > /dev/null; then \
echo "error: protoc not installed" >&2; \
exit 1; \
fi
@ if ! which protoc-gen-go > /dev/null; then \
echo "error: protoc-gen-go not installed" >&2; \
exit 1; \
fi
@ if ! which protoc-gen-go-grpc > /dev/null; then \
echo "error: protoc-gen-go-grpc not installed" >&2; \
exit 1; \
fi
@ if ! which protoc-gen-micro > /dev/null; then \
echo "error: protoc-gen-micro not installed" >&2; \
exit 1; \
fi
for file in $$(git ls-files '*.proto'); do \
protoc -I $$(dirname $$file) \
--go_out=:$$(dirname $$file) --go_opt=paths=source_relative \
--go-grpc_out=:$$(dirname $$file) --go-grpc_opt=paths=source_relative \
--micro_out=:$$(dirname $$file) --micro_opt=paths=source_relative \
$$file; \
done
@jxlwqq
Copy link
Author

jxlwqq commented Oct 12, 2021

If Not Installed:

brew install protobuf
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
go install github.com/asim/go-micro/cmd/protoc-gen-micro/v3@latest

Reference:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment