콘텐츠로 이동

goctl RPC

Terminal window
$ goctl rpc --help
Generate rpc code
Usage:
goctl rpc [flags]
goctl rpc [command]
Available 명령s:
new Generate rpc demo service
protoc Generate grpc code
template Generate proto template
Flags:
--branch string The branch of the remote repo, it does work with --remote
-h, --help help for rpc
--home string The goctl home path of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority
--o string Output a sample proto file
--remote string The remote git repo of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority
The git repo directory must be consistent with the https://github.com/zeromicro/go-zero-template directory structure
Use "goctl rpc [command] --help" for more information about a command.
매개변수 필드 매개변수 타입 필수? 기본값 value 매개변수 설명
branchstring없음Empty string템플릿 repository branch, 사용하여 —remote usage
homestring없음~/.goctl템플릿 repository 로컬 경로 higher than —remote
ostring없음Empty string출력 api 파일
원격string없음Empty string템플릿 repository 원격 경로

예제:생성합니다 proto 파일

Terminal window
$ goctl rpc --o greet.proto
Terminal window
$ goctl rpc new --help
Generate rpc demo service
Usage:
goctl rpc new [flags]
Flags:
--branch string The branch of the remote repo, it does work with --remote
-h, --help help for new
--home string The goctl home path of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority
--idea Whether the command execution environment is from idea plugin.
--remote string The remote git repo of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority
The git repo directory must be consistent with the https://github.com/zeromicro/go-zero-template directory structure
--style string The file naming format, see [https://github.com/zeromicro/go-zero/tree/master/tools/goctl/config/readme.md] (default "gozero")
-v, --verbose Enable log output
매개변수 필드 매개변수 타입 필수? 기본값 value 매개변수 설명
branchstring없음Empty string템플릿 repository branch, 사용하여 —remote usage
homestring없음~/.goctl템플릿 repository 로컬 경로 higher than —remote
ideabool없음false사용 this 필드 만 위한 플러그인, please ignore this 필드
원격string없음Empty string템플릿 repository 원격 경로
스타일string없음gozeroFilename 스타일, see 파일 스타일

생성 rpc 서비스 based 에서 protobefer 파일.

Terminal window
$ goctl rpc protoc --help
Generate grpc code
Usage:
goctl rpc protoc [flags]
Examples:
goctl rpc protoc xx.proto --go_out=./pb --go-grpc_out=./pb --zrpc_out=.
Flags:
--branch string The branch of the remote repo, it does work with --remote
-h, --help help for protoc
--home string The goctl home path of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority
-m, --multiple Generated in multiple rpc service mode
--remote string The remote git repo of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority
The git repo directory must be consistent with the https://github.com/zeromicro/go-zero-template directory structure
--style string The file naming format, see [https://github.com/zeromicro/go-zero/tree/master/tools/goctl/config/readme.md] (default "gozero")
-v, --verbose Enable log output
--zrpc_out string The zrpc output directory
매개변수 필드 매개변수 타입 필수? 기본값 value 매개변수 설명
branchstring없음Empty string템플릿 repository branch, 사용하여 —remote usage
homestring없음~/.goctl템플릿 repository 로컬 경로 higher than —remote
multiplebool없음falseWhether 로 생성 multiple rpc 서비스
원격string없음Empty string템플릿 repository 원격 경로
스타일string없음gozeroFilename 스타일, see 파일 스타일

예제:

Terminal window
# 예시입니다
$ goctl rpc protoc greet.proto --go_out=./pb --go-grpc_out=./pb --zrpc_out=.
# 예시입니다
$ goctl rpc protoc greet.proto --go_out=./pb --go-grpc_out=./pb --zrpc_out=. -m
Terminal window
$ goctl rpc template --help
Generate proto template
Usage:
goctl rpc template [flags]
Flags:
--branch string The branch of the remote repo, it does work with --remote
-h, --help help for template
--home string The goctl home path of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority
--o string Output a sample proto file
--remote string The remote git repo of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority
The git repo directory must be consistent with the https://github.com/zeromicro/go-zero-template directory structure
매개변수 필드 매개변수 타입 필수? 기본값 value 매개변수 설명
branchstring없음Empty string템플릿 repository branch, 사용하여 —remote usage
homestring없음~/.goctl템플릿 repository 로컬 경로 higher than —remote
ostring없음Empty string출력 파일 경로
원격string없음Empty string템플릿 repository 원격 경로

예제:

Terminal window
$ goctl rpc template -o greet.proto