Skip to content

Commit fe65123

Browse files
committed
feat(client): add protobuf to Go code generation script
1 parent 18146ee commit fe65123

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

client/dtmgrpc/dtmgpb/proto2go.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Step 1: Get and configure GOPATH (temporary effect)
2+
# Get GOPATH and assign to variable (automatically adapt your path)
3+
GOPATH=$(go env GOPATH)
4+
# Add GOPATH/bin to PATH (solve plugin not found issue)
5+
export PATH=$PATH:$GOPATH/bin
6+
7+
# Step 2: Verify if plugins exist (optional but recommended)
8+
# Check if protoc-gen-go exists
9+
if [ -f "$GOPATH/bin/protoc-gen-go" ]; then
10+
echo "protoc-gen-go plugin exists"
11+
else
12+
echo "protoc-gen-go plugin doesn't exist, installing..."
13+
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
14+
fi
15+
16+
# Check if protoc-gen-go-grpc exists
17+
if [ -f "$GOPATH/bin/protoc-gen-go-grpc" ]; then
18+
echo "protoc-gen-go-grpc plugin exists"
19+
else
20+
echo "protoc-gen-go-grpc plugin doesn't exist, installing compatible version..."
21+
# Use version compatible with project gRPC v1.56.3
22+
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0
23+
fi
24+
25+
26+
# Step 3: Generate Go code (core command)
27+
# Generate basic pb.go file
28+
protoc --go_out=. --go_opt=paths=source_relative dtmgimp.proto
29+
# Generate grpc related pb.go file
30+
protoc --go-grpc_out=. --go-grpc_opt=paths=source_relative dtmgimp.proto

0 commit comments

Comments
 (0)