goctl

command module
v1.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2024 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

goctl

Go Report Card goproxy Release

重要!

原仓库地址:https://github.com/zeromicro/go-zero/tree/master/tools/goctl
主要根据原仓库的 goctl 对 api 和 rpc 代码的生成等做了一些定制化的修改
基于 goctl 1.6.5 版本:https://github.com/zeromicro/go-zero/tree/v1.6.5/tools/goctl

安装

需要 go 1.19 以上版本编译安装

# 可选:自行编译安装(代码最新):
$ git clone https://github.com/sliveryou/goctl.git
$ cd goctl
$ go install

# 推荐:使用如下命令安装:
$ go install github.com/sliveryou/goctl@latest

或者从 github 的 release 页面下载预编译好的二进制文件

改动

  1. 优化:当有一个 api 文件,如 base.api 文件 import 了多个 api 文件时,这些 api 文件可以跨文件共享定义好的结构体,方便一些公有结构体放在 common.api 中,其他文件共用
  2. 优化:增加 goctl api proto 命令,可以基于 api 文件生成 proto 文件,使用例子:goctl api proto --api base.api --dir .
  3. 优化:支持生成 handler 相关文件时增加 swag 注解,需使用项目内模板 .goctl,使用例子:goctl api go --api base.api --dir . --home .goctl
    1. 配合 swag 工具可以生成 swagger 文档和 swagger 服务,使用例子:swag init -d . -g main.go -p snakecase --ot go,json,yaml -o docs
    2. 可以将项目内模板作为 goctl 执行默认模板,命令:mkdir -p ~/.goctl/1.6.5 && cp -r .goctl/* ~/.goctl/1.6.5
  4. 优化:增加 goctl rpc client 命令,可以基于 proto 文件只生成适配 go-zero 的 grpc client 代码,用法与 goctl rpc protoc 相同
  5. 优化:增加 rpc 记录日志,需要修改本地 goctl 模板,参考 .goctl/rpc/logic.tpl
  6. 优化:增加 api 记录日志,需要修改本地 goctl 模板,参考 .goctl/api/logic.tpl

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL