# go-tools **Repository Path**: flamez57/go-tools ## Basic Information - **Project Name**: go-tools - **Description**: 码农必备小工具 - **Primary Language**: Go - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-10-05 - **Last Updated**: 2024-10-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # go-tools #### 介绍 码农必备小工具 #### 软件架构 ``` ├── cmd ·················· 存放命令 │  ├── root.go ·········· 所有命令都要在这里注册 │  ├── sql.go ··········· sql相关命令 │  ├── time.go ·········· 时间转换相关命令 │   └── word.go ·········· 单词转换相关命令 ├── internal ············· 支持命令的一些函数 │  ├── sql2struct ······· 数据库操作相关函数 │  │  ├── mysql.go │  │  └── template.go │  ├── timer ············ 时间转换相关函数 │  │  └── time.go │   └── word ············· 单词转换相关函数 │    └── word.go ├── go.mod ├── go.sum └── main.go ··············· 项目入口 ``` #### 单词格式转换使用说明 查看帮助 ```cmd go run main.go help word ``` ```cmd PS E:\my_code\go-tools> go run main.go help word 该子命令支持各种单词格式转换,模式如下: 1:全部单词转换为大写 2:全部单词转换为小写 3:下划线单词转换为大写驼峰单词 4:下划线单词转换为小写驼峰单词 5:驼峰单词转换为下划线单词 Usage: word [flags] Flags: -h, --help help for word -m, --mode int8 请输入单词转换模式 -s, --str string 请输入单词内容 PS E:\my_code\go-tools> ``` 全部转大写 ```cmd PS E:\my_code\go-tools> go run main.go word -s=heloword -m=1 2024/10/05 12:34:35 输出结果: HELOWORD ``` 全部转小写 ```cmd PS E:\my_code\go-tools> go run main.go word -s=HELOWORD -m=2 2024/10/05 12:34:50 输出结果: heloword ``` 转大驼峰 ```cmd PS E:\my_code\go-tools> go run main.go word -s=helo_word -m=3 2024/10/05 12:36:23 输出结果: HeloWord ``` 转小驼峰 ```cmd PS E:\my_code\go-tools> go run main.go word -s=helo_word -m=4 2024/10/05 12:36:33 输出结果: heloWord ``` 驼峰转下划线 ```cmd PS E:\my_code\go-tools> go run main.go word -s=heloWord -m=5 2024/10/05 12:36:49 输出结果: helo_word ``` 不存在 ```cmd PS E:\my_code\go-tools> go run main.go word -s=heloword -m=6 2024/10/05 12:35:15 暂不支持该转换模式,请执行 help word 查看帮助文档 exit status 1 ``` #### 时间工具使用说明 ```cmd PS E:\my_code\go-tools> go run main.go help time 时间格式处理 Usage: time [flags] time [command] Available Commands: calc 计算所需的时间 now 获取当前时间 stamp 时间戳解析 Flags: -h, --help help for time Use " time [command] --help" for more information about a command. ``` 当前时间时间戳 ```cmd PS E:\my_code\go-tools> go run main.go time now 2024/10/05 13:23:19 输出结果: 2024-10-05 13:23:19, 1728105799 ``` 两小时前 ```cmd PS E:\my_code\go-tools> go run main.go time calc -c="2024-10-05 13:14:13" -d=-2h 2024/10/05 13:31:16 输出结果:2024-10-05 11:14:13, 1728126853 ``` 5分钟后 ```cmd PS E:\my_code\go-tools> go run main.go time calc -c="2024-10-05 13:14:13" -d=5m 2024/10/05 13:31:26 输出结果:2024-10-05 13:19:13, 1728134353 ``` 指定时间 ```cmd PS E:\my_code\go-tools> go run main.go time calc -c="2024-10-05 13:14:13" -d=0 2024/10/05 13:36:09 输出结果:2024-10-05 13:14:13, 1728134053 ``` 时间戳解析 ```cmd PS E:\my_code\go-tools> go run main.go time stamp -s=1728134053 2024/10/05 13:48:24 输出结果:2024-10-05 21:14:13, 1728134053 ``` #### sql语句到结构体的转换 帮助查看 ```cmd PS E:\my_code\go-tools> go run main.go help sql sql 转换和处理 Usage: sql [flags] sql [command] Available Commands: struct sql 转换 Flags: -h, --help help for sql Use " sql [command] --help" for more information about a command. ``` 子命令帮助查看 ```cmd PS E:\my_code\go-tools> go run main.go sql struct --help sql 转换 Usage: sql struct [flags] Flags: -c, --charset string 请输入数据库编码 (default "utf8mb4") --db string 请输入数据库名称 -h, --help help for struct --host string 请输入数据库HOST (default "127.0.0.1:3306") -p, --password string 请输入数据库密码 --table string 请输入数据表名称 -t, --type string 请输入数据库实力类型 (default "mysql") -u, --username string 请输入数据库账号 ``` 指定表转对应的model ```cmd go run main.go sql struct -u=whole -p="Qwe_1.3.14" --host=49.235.118.244:3306 --db=flamez_test --table=my_district ```