mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-14 02:10:00 +08:00
feat(goctl/rpc): support external proto imports with cross-package ty… (#5472)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
39
tools/goctl/rpc/test/proto/04_transitive/gen.sh
Executable file
39
tools/goctl/rpc/test/proto/04_transitive/gen.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
# Scenario 04: transitive imports
|
||||
# Usage: bash gen.sh
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
GOCTL_ROOT="$(cd "$SCRIPT_DIR/../../../.." && pwd)"
|
||||
GOCTL="$GOCTL_ROOT/bin/goctl"
|
||||
OUT="$SCRIPT_DIR/output"
|
||||
|
||||
# Build goctl from source
|
||||
go build -o "$GOCTL" "$GOCTL_ROOT"
|
||||
|
||||
# Clean and initialize output directory
|
||||
rm -rf "$OUT" && mkdir -p "$OUT/pb"
|
||||
(cd "$OUT" && go mod init example.com/demo/s04_transitive > /dev/null 2>&1)
|
||||
|
||||
# Generate code
|
||||
cd "$SCRIPT_DIR"
|
||||
"$GOCTL" rpc protoc main.proto \
|
||||
--go_out="$OUT/pb" \
|
||||
--go-grpc_out="$OUT/pb" \
|
||||
--zrpc_out="$OUT/rpc" \
|
||||
--go_opt=paths=source_relative \
|
||||
--go-grpc_opt=paths=source_relative \
|
||||
--proto_path=.
|
||||
|
||||
# Verify build
|
||||
echo "Running go mod tidy..."
|
||||
cd "$OUT" && go mod tidy
|
||||
echo "Checking build..."
|
||||
if go build ./...; then
|
||||
echo "✅ Build passed"
|
||||
else
|
||||
echo "❌ Build failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Done. Output: $OUT"
|
||||
Reference in New Issue
Block a user