glennctl

command module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: GPL-3.0 Imports: 3 Imported by: 0

README

glennctl

简体中文 | English

glennctl 是基于 go-zero 增强的代码生成与脚手架工具,统一以 glennctl 命令使用(不再支持 goctl)。

安装

  • 安装最新版本:
go install github.com/GlennLiu0607/glennctl@latest
  • 验证安装:
glennctl -h
glenn -h

模板管理

  • 初始化所有内置模板:
glennctl template init
  • 指定模板目录初始化:
glennctl template init --home ./_templates
  • 更新某一分类模板(示例:TDengine):
glennctl template update -c tdengine --home ./_templates
  • 回滚某一分类的指定模板文件:
glennctl template revert -c tdengine -n model.tpl --home ./_templates

RPC 代码生成

  • 创建新的 zRPC 服务骨架:
glennctl rpc new user --module github.com/your/repo --style go_zero
  • 从 .proto 生成 zRPC 目录结构(单服务):
glennctl rpc protoc ./idl/user.proto --zrpc_out ./rpc/user --style go_zero
  • 多服务模式:
glennctl rpc protoc ./idl/service.proto --zrpc_out ./rpc/service -m

API 代码生成

  • 新建 API 项目:
glennctl api new user-api --module github.com/your/repo --style go_zero
  • 从 .api 文件生成 Go 服务骨架:
glennctl api go --api ./api/user.api --dir ./api/user --style go_zero
  • 生成文档与校验:
glennctl api doc --dir ./api/user -o ./api/user/openapi.json
glennctl api validate --api ./api/user.api

模型生成(SQL / Mongo / TDengine)

  • 对应模型生成命令依照 go-zero 保持一致;
  • 使用模板管理命令可对 sqlmongotdengine 分类模板进行初始化、更新与回滚:
glennctl template update -c sql
glennctl template update -c mongo
glennctl template update -c tdengine

常用选项说明

  • --home 指定模板根目录
  • --remote 指定远程模板仓库
  • --branch 指定模板分支
  • --style 文件命名风格(默认 go_zero
  • -v/--verbose 输出更多日志

发布说明

  1. 移除 go.mod 中的 replace 指令(发布模块不允许包含会改变解析的 replace)。
  2. 模块路径必须与仓库地址一致:
    • 若发布到 github.com/GlennLiu0607/glennctl,请将 go.mod 第一行修改为 module github.com/GlennLiu0607/glennctl,并统一更新项目内的 import 前缀为该模块路径;
    • 若保持 github.com/GlennLiu0607/glennctl,则仓库地址需与之匹配,安装时使用该路径。
  3. 推送代码到远端仓库并打版本标签:
git tag v1.0.0
git push origin v1.0.0
  1. 用户安装方式:
go install github.com/GlennLiu0607/glennctl@v1.0.0
  1. 验证:
glennctl version
glennctl -h

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
api
gogen
* @Author: GlennLiu <glennliu0607@gmail.com> * @Date: 2025-10-28 13:55:07 * @LastEditors: Glenn 18322653727@163.com * @LastEditTime: 2025-10-28 14:08:08 * @FilePath: \glennctl\api\gogen\gen.go * @Description: * * Copyright (c) 2025 by 天津晟源士兴科技有限公司, All Rights Reserved.
* @Author: GlennLiu <glennliu0607@gmail.com> * @Date: 2025-10-28 13:55:07 * @LastEditors: Glenn 18322653727@163.com * @LastEditTime: 2025-10-28 14:08:08 * @FilePath: \glennctl\api\gogen\gen.go * @Description: * * Copyright (c) 2025 by 天津晟源士兴科技有限公司, All Rights Reserved.
javagen
* @Author: GlennLiu <glennliu0607@gmail.com> * @Date: 2025-10-28 13:55:07 * @LastEditors: Glenn 18322653727@163.com * @LastEditTime: 2025-10-28 14:04:10 * @FilePath: \glennctl\api\javagen\gencomponents.go * @Description: * * Copyright (c) 2025 by 天津晟源士兴科技有限公司, All Rights Reserved.
* @Author: GlennLiu <glennliu0607@gmail.com> * @Date: 2025-10-28 13:55:07 * @LastEditors: Glenn 18322653727@163.com * @LastEditTime: 2025-10-28 14:04:10 * @FilePath: \glennctl\api\javagen\gencomponents.go * @Description: * * Copyright (c) 2025 by 天津晟源士兴科技有限公司, All Rights Reserved.
new
example
rpc/hello command
rpc/hi command
internal
pkg
env
demo command
rpc
cli
* @Author: GlennLiu <glennliu0607@gmail.com> * @Date: 2025-10-28 13:55:09 * @LastEditors: Glenn 18322653727@163.com * @LastEditTime: 2025-10-28 14:06:08 * @FilePath: \glennctl\upgrade\upgrade.go * @Description: * * Copyright (c) 2025 by 天津晟源士兴科技有限公司, All Rights Reserved.
* @Author: GlennLiu <glennliu0607@gmail.com> * @Date: 2025-10-28 13:55:09 * @LastEditors: Glenn 18322653727@163.com * @LastEditTime: 2025-10-28 14:06:08 * @FilePath: \glennctl\upgrade\upgrade.go * @Description: * * Copyright (c) 2025 by 天津晟源士兴科技有限公司, All Rights Reserved.
ctx
env
name
Package name provides methods to verify naming style and format naming style See the method IsNamingValid, FormatFilename
Package name provides methods to verify naming style and format naming style See the method IsNamingValid, FormatFilename

Jump to

Keyboard shortcuts

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