File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments