콘텐츠로 이동

goctl API

Terminal window
$ goctl api --help
Generate api related files
Usage:
goctl api [flags]
goctl api [command]
Available 명령s:
dart Generate dart files for provided api in api file
doc Generate doc files
format Format api files
go Generate go files for provided api in api file
kt Generate kotlin code for provided api file
new Fast create api service
plugin Custom file generator
swagger Generate swagger file from api
ts Generate ts files for provided api in api file
validate Validate api file
Flags:
--branch string The branch of the remote repo, it does work with --remote
-h, --help help for api
--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 api 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 api [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 원격 경로

생성 date code 에서 api 파일.

Terminal window
$ goctl api dart --help
Generate dart files for provided api in api file
Usage:
goctl api dart [flags]
Flags:
--api string The api file
--dir string The target dir
-h, --help help for dart
--hostname string hostname of the server
--legacy Legacy generator for flutter v1
매개변수 필드 매개변수 타입 필수? 기본값 value 매개변수 설명
apistringYESEmpty stringapi 파일
dirstringYESEmpty string생성 Code 출력 디렉터리
hostnamestring없음go-zero.dev호스트 值
legacyboolean없음falseWhether 또는 아님 older 버전

생성 markdown 문서화 based 에서 api 파일.

Terminal window
$ goctl api doc --help
Generate doc files
Usage:
goctl api doc [flags]
Flags:
--dir string The target dir
-h, --help help for doc
--o string The output markdown directory
매개변수 필드 매개변수 타입 필수? 기본값 value 매개변수 설명
dirstringYESEmpty stringapi 파일 디렉터리
ostring없음Current 작동 dirDocument 출력 디렉터리

Api 파일 에서 recursive formatting 디렉터리.

Terminal window
$ goctl api format --help
Format api files
Usage:
goctl api format [flags]
Flags:
--declare Use to skip check api types already declare
--dir string The format target dir
-h, --help help for format
--iu Ignore update
--stdin Use stdin to input api doc content, press "ctrl + d" to send EOF
매개변수 필드 매개변수 타입 필수? 기본값 value 매개변수 설명
declareboolean없음falseWhether 로 detect 컨텍스트
dirstringYESEmpty stringapi 파일 디렉터리
iu---Unused 필드 pending removal
stdinboolean없음falseFormat api content 위한 terminal 입력

생성 Go HTTP code 에서 api 파일.

Terminal window
$ goctl api go --help
Generate go files for provided api in api file
Usage:
goctl api go [flags]
Flags:
--api string The api file
--branch string The branch of the remote repo, it does work with --remote
--dir string The target dir
-h, --help help for go
--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
--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/blob/master/tools/goctl/config/readme.md] (default "gozero")
매개변수 필드 매개변수 타입 필수? 기본값 value 매개변수 설명
apistringYESEmpty stringapi 파일
branchstring없음Empty string원격 템플릿 name is 사용됨 만 경우 remote has value
dirstring없음Current 작동 디렉터리생성 Code 출력 디렉터리
homestring없음${HOME}/.goctl로컬 템플릿 파일 디렉터리
원격string없음Empty string해당 항목의 동작과 사용법을 설명합니다.
스타일string없음gozeroNamed 스타일 symbols 위한 출력 파일과 디렉터리, see 파일 스타일
Terminal window
$ goctl api new --help
Fast create api service
Usage:
goctl api new [flags]
Examples:
goctl api new [options] service-name
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
--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/blob/master/tools/goctl/config/readme.md] (default "gozero")
매개변수 필드 매개변수 타입 필수? 기본값 value 매개변수 설명
branchstring없음Empty string원격 템플릿 name is 사용됨 만 경우 remote has value
homestring없음${HOME}/.goctl로컬 템플릿 파일 디렉터리
원격string없음Empty string해당 항목의 동작과 사용법을 설명합니다.
스타일string없음gozeroNamed 스타일 symbols 위한 출력 파일과 디렉터리, see 파일 스타일

:::note reminder

Terminal window
$ goctl api new demo

:::

Terminal window
$ goctl api plugin --help
Custom file generator
Usage:
goctl api plugin [flags]
Flags:
--api string The api file
--dir string The target dir
-h, --help help for plugin
-p, --plugin string The plugin file
--style string The file naming format, see [https://github.com/zeromicro/go-zero/tree/master/tools/goctl/config/readme.md]
매개변수 필드 매개변수 타입 필수? 기본값 value 매개변수 설명
apistringYESEmpty stringapi 파일
dirstring없음Current 작동 디렉터리api 파일
플러그인stringYESEmpty string경로 로 플러그인 executable, 지원 로컬과 HTML 파일
스타일string없음gozeroNamed 스타일 symbols 위한 출력 파일과 디렉터리, see 파일 스타일

플러그인 resource 참조: goctl 플러그인 resource

:::note Tips 이 항목은 해당 기능의 사용 방법, 설정, 주의 사항을 설명합니다.

  1. 버전 의 goctl은 greater than 1.8.2입니다. :::
Terminal window
goctl api swagger -h
Generate swagger file from api
Usage:
goctl api swagger [flags]
Flags:
--api string The api file
--dir string The target dir
-h, --help help for swagger
--yaml Generate swagger yaml file, default to json
매개변수 필드 매개변수 타입 필수? 기본값 value 매개변수 설명
apistringYESempty stringapi filename
dirstring없음작동 디렉터리출력 dir
yamlbool없음falseformat to yaml file

생성 TypeScript code 에서 api 파일.

Terminal window
$ goctl api ts --help
Generate ts files for provided api in api file
Usage:
goctl api ts [flags]
Flags:
--api string The api file
--caller string The web api caller
--dir string The target dir
-h, --help help for ts
--unwrap Unwrap the webapi caller for import
--webapi string The web api file path
매개변수 필드 매개변수 타입 필수? 기본값 value 매개변수 설명
apistringYESEmpty stringapi 파일
dirstring없음Current 작동 디렉터리api 파일
callerstring없음webapiweb caller,
플러그인stringYESEmpty string경로 로 플러그인 executable, 지원 로컬과 HTML 파일
스타일string없음gozeroNamed 스타일 symbols 위한 출력 파일과 디렉터리, see 파일 스타일

확인 that api 파일 meet specifications.

Terminal window
goctl api validate --help
Validate api file
Usage:
goctl api validate [flags]
Flags:
--api string Validate target api file
-h, --help help for validate
매개변수 필드 매개변수 타입 필수? 기본값 value 매개변수 설명
apistringYESEmpty stringapi 파일