# godb **Repository Path**: stylesmile/godb ## Basic Information - **Project Name**: godb - **Description**: No description available - **Primary Language**: Go - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-07-22 - **Last Updated**: 2026-07-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # GoDB - 数据库管理工具 GoDB 是一款基于 Go + [Fyne](https://fyne.io/) 构建的轻量级跨平台数据库桌面管理工具,旨在为开发者和 DBA 提供简洁高效的多数据库统一操作界面。 ## 功能特性 - **多数据库支持**:MySQL、PostgreSQL、Kingbase(人大金仓)、Redis、MongoDB - **统一连接管理**:可视化树形侧边栏,支持新建、编辑、删除连接 - **SQL 编辑与执行**:内置 SQL 编辑器,支持查询和 DDL/DML 语句执行,结果实时展示 - **表结构浏览**:查看数据库列表、表列表及字段元数据(类型、主键、注释等) - **Redis 键管理**:按 pattern 检索键、查看键值与 TTL、删除键 - **配置持久化**:连接信息和窗口状态自动保存至 `~/.godb/`,下次启动自动恢复 - **跨平台**:支持 Windows、macOS、Linux ## 快速开始 ### 环境要求 | 依赖 | 版本 | 说明 | |---|---|---| | Go | ≥ 1.22 | 项目使用 Go Modules | | GCC (C 编译器) | MinGW-w64 或 TDM-GCC | Fyne 依赖 CGo,**必须安装** | ### 安装 C 编译器(必须) Fyne 框架依赖 CGo,编译时需要 C 编译器。**不安装将报 `build constraints exclude all Go files` 错误。** **Windows(推荐 TDM-GCC):** 1. 下载 [TDM-GCC](https://jmeubank.github.io/tdm-gcc/download/) 2. 安装时勾选 **Add to PATH** 3. 重启终端,验证:`gcc --version` **macOS:** ```bash xcode-select --install ``` **Linux (Debian/Ubuntu):** ```bash sudo apt-get install gcc libgl1-mesa-dev libgtk-3-dev ``` ### 克隆 & 运行 ```bash git clone https://github.com/godb-0722/godb.git cd godb go mod tidy ``` ```bash # Windows $env:CGO_ENABLED = "1" go run ./cmd/godb # macOS / Linux CGO_ENABLED=1 go run ./cmd/godb ``` ### 编译为可执行文件 ```bash # Windows $env:CGO_ENABLED = "1" go build -o godb.exe ./cmd/godb # macOS / Linux CGO_ENABLED=1 go build -o godb ./cmd/godb ``` ## 支持的数据库 | 数据库 | 驱动 | 默认端口 | |---|---|---| | MySQL | `go-sql-driver/mysql` | 3306 | | PostgreSQL | `lib/pq` | 5432 | | Kingbase(人大金仓) | `lib/pq`(兼容 PG 协议) | 54321 | | Redis | `go-redis/v9` | 6379 | | MongoDB | `mongo-driver` | 27017 | ## 项目结构 ``` godb/ ├── cmd/godb/main.go # 程序入口 ├── internal/ │ ├── config/config.go # 配置管理(连接持久化、窗口状态) │ ├── database/ # 各数据库驱动实现 │ │ ├── mysql.go │ │ ├── postgresql.go │ │ ├── redis.go │ │ ├── mongodb.go │ │ ├── kingbase.go │ │ └── types.go # 接口定义 + 工厂函数 │ ├── model/model.go # 数据模型定义 │ └── ui/main_window.go # Fyne GUI 界面 ├── test/ # 外部包单元测试 ├── docs/ # 文档 ├── go.mod └── go.sum ``` ## 运行测试 ```bash # 全部测试(不需要真实数据库连接) go test ./internal/database/... ./test/... -v -count=1 # 仅 model 测试 go test ./test/internal/model/... -v -count=1 # 仅 config 测试 go test ./test/internal/config/... -v -count=1 ``` ## 常见问题 ### 启动报错 `build constraints exclude all Go files` 没有安装 C 编译器(gcc),CGo 无法工作。按上面的步骤安装 TDM-GCC 或 MinGW-w64。 ### `go build` 报错 `cgo: exec gcc: missing or not executable` gcc 未安装或不在 PATH 中。重启终端让 PATH 生效,或手动检查 `where gcc`。 ### Linux 下报错缺少 OpenGL 库 ```bash sudo apt-get install libgl1-mesa-dev xorg-dev ``` ## License MIT