All apps/goctl

goctl

goctl

A go-zero companion code generation tool that integrates Go HTTP, Go gRPC services, database model, k8s, Dockerfile and more.

Runs as goctl|macOS, Linux, Windows|go-zero.dev

Command form

ai-draft · 5 tasks · 22 fields

Generate go-zero API code, Dockerfiles and MySQL models. The rpc, kube, template and migrate commands are left out.

Opens the form; the finished command lands at your prompt, unrun
otty gui goctl

goctl api go

Generate API service code

Generate Go files for an .api file.

Generate API service codeExample values, fixed in this page — nothing here reaches a terminal
Basic
API file*
file
Target directory*
directory
File naming style
string
TasksEach one presets the form for one job
Generate
apidirstyle
ParametersOnly these flags are editable in the form
API file
path
--api
Target directory
path
--dir
Template home
Local template directory; cannot be combined with --remote.
string
--home
Template repo
Remote git repo of the template; wins over --home.
string
--remote
File naming style
string
--style

goctl api format

Format API files

Format .api files in a directory.

Format API filesExample values, fixed in this page — nothing here reaches a terminal
Basic
Directory*
directory
TasksEach one presets the form for one job
Format
dir
ParametersOnly these flags are editable in the form
Directory
path
--dir
Skip declared-type check
boolean
--declare
Ignore update
boolean
--iu
Read from stdin
boolean
--stdin

goctl docker

Generate Dockerfile

Generate a Dockerfile for a Go service.

Generate DockerfileExample values, fixed in this page — nothing here reaches a terminal
Basic
Main file*
file
Base image
string
Exposed port
string
Advanced
Timezone
string
TasksEach one presets the form for one job
Dockerfile
gobaseporttz
ParametersOnly these flags are editable in the form
Main file
File that contains the main function.
path
--go
Base image
Defaults to scratch.
string
--base
Exposed port
string
--port
Timezone
string
--tz
Builder Go version
string
--version
Template home
string
--home

goctl model mysql datasource

Generate MySQL model

Generate model code from a live MySQL data source.

Generate MySQL modelExample values, fixed in this page — nothing here reaches a terminal
Basic
Data source URL*
string
Table pattern*
string
Target directory*
directory
With cache
--cache
TasksEach one presets the form for one job
Generate model
urltabledircache
ParametersOnly these flags are editable in the form
Data source URL
For example root:password@tcp(127.0.0.1:3306)/database.
string
--url
Table pattern
string
--table-t
Target directory
path
--dir-d
With cache
boolean
--cache-c
File naming style
string
--style
For IDEA plugin
boolean
--idea

goctl quickstart

Quick start

Create and start a sample project.

Quick startExample values, fixed in this page — nothing here reaches a terminal
Basic
Service type
2 choicesenum
TasksEach one presets the form for one job
Quick start
service_type
ParametersOnly these flags are editable in the form
Service type
enum
--service-type-tmonomicro
SourcesEvery flag above is checked against these
fig
completion

github.com

fig
completion

github.com

fig
completion

github.com

fig
completion

github.com

fig
completion

github.com

fig
completion

github.com

Before it fills your prompt, Otty checks the installed goctl against its version. A form that does not match your version is not offered.