2021-01-17 05:31:00 +08:00

68 lines
1.8 KiB
Makefile

.PHONY:all
clean:
rm -rf ./gen/proto* /gen/openapi2/*
gofmt:
find . -name "*.go" \
-not -path "./gen" \
-not -path ".git/*" \
| xargs gofmt -s -d -w
all:
protoc \
--proto_path ./protos \
--go_out ./gen/proto --go_opt paths=source_relative \
--go-grpc_out ./gen/proto --go-grpc_opt paths=source_relative \
--grpc-gateway_out ./gen/proto \
--grpc-gateway_opt paths=source_relative \
--grpc-gateway_opt logtostderr=true \
--grpc-gateway_opt generate_unbound_methods=true \
--openapiv2_out ./gen/openapi2 \
--openapiv2_opt logtostderr=true \
./protos/echo/v1/echo.proto
grpc:
protoc \
--proto_path ./protos \
--go_out ./gen/proto --go_opt paths=source_relative \
--go-grpc_out ./gen/proto --go-grpc_opt paths=source_relative \
./protos/echo/v1/echo.proto
gateway:
protoc \
--proto_path ./protos \
--grpc-gateway_out ./gen/proto \
--grpc-gateway_opt paths=source_relative \
--grpc-gateway_opt logtostderr=true \
--grpc-gateway_opt generate_unbound_methods=true \
./protos/echo/v1/echo.proto
openapi:
protoc \
--proto_path ./protos \
--openapiv2_out ./gen/openapi2 \
--openapiv2_opt logtostderr=true \
/protos/echo/v1/echo.proto
certs:
openssl genrsa -out ca.key 2048
openssl req -new -x509 -days 3650 \
-subj "/C=GB/L=China/O=gobook/CN=github.com" \
-key ca.key -out ca.crt
openssl req -new \
-subj "/C=GB/L=China/O=server/CN=server.io" \
-key server.key \
-out server.csr
openssl x509 -req -sha256 \
-CA ca.crt -CAkey ca.key -CAcreateserial -days 3650 \
-in server.csr \
-out server.crt
openssl req -new \
-subj "/C=GB/L=China/O=client/CN=client.io" \
-key client.key \
-out client.csr
openssl x509 -req -sha256 \
-CA ca.crt -CAkey ca.key -CAcreateserial -days 3650 \
-in client.csr \
-out client.crt