MyGoland 首次提交:Go 轻量 IDE

- 编辑器:多标签、语法高亮、gopls 全套(补全/诊断/跳转/重命名/代码动作/内联提示/签名大纲)
- 调试:Delve DAP(断点/条件断点/变量树/表达式求值/goroutine 列表)
- 测试:结果树、覆盖率行着色、失败跳源码、-run 精确运行、行号可跑标记
- Git:状态着色、选择性暂存提交、pull/push、历史并排对比
- 本地历史 + 自动快照 + 崩溃恢复、会话/光标恢复
- 全局搜索替换(预览+确认,GBK 安全)、多终端、gopls 崩溃自愈
- 设计文档与验证记录见 docs/plans/
This commit is contained in:
zerorigin committed 2026-11-04 16:37:05 +08:00
commit a80c0f886a
220 files changed
+20784

No files matched your search

+210
View File
@@ -0,0 +1,210 @@
# MyGoland 与 GoLand 差距分析
> 基准:GoLand 2025.x(JetBrains 官方功能说明)
> 现状:MyGoland v0.1(本次 13 项开发完成后的状态)
> 目的:找出「还差什么」,以及「哪些值得做、哪些不值得」
---
## 一、总体结论
| 维度 | GoLand | MyGoland 现状 | 差距 |
|---|---|---|---|
| 编辑体验 | 完善(折叠/内联提示/模板/多光标/查找替换) | 基础可用,缺折叠入口、内联提示、查找替换、模板 | **大** |
| 代码理解 | gopls + 自研索引 | gopls(诊断/补全/定义/引用/重命名/代码动作/大纲) | **小** |
| 导航 | 全局符号/文件/动作/书签/最近 | 文件、动作、引用、最近、大纲、面包屑;缺全局符号 | 中 |
| 重构 | 自有实现(改签名/提取/内联/移动/安全删除) | 靠 gopls 代码动作,UI 未归类 | 中 |
| 调试 | 全功能(goroutine/watch/attach/core dump) | 变量/调用栈/求值/条件断点 | 中 |
| 测试 | 结果树 + 覆盖率 + 单测跳转 | 只有 `go test` 文本输出 | **大** |
| 版本控制 | diff/历史/blame/分支/冲突解决 | 状态着色 + 提交 | **大** |
| 工程工具 | DB/SQL、Docker/K8s、Proto、远程开发 | 无 | 极大(不建议追) |
| 生态 | 上千插件、IdeaVim、AI | 无 | 极大(不需要) |
| 启动与体积 | 10–20 秒 / 800 MB+ | **约 1 秒 / 15 MB** | 我们更好 |
一句话:**代码智能这一层已经追平(都靠 gopls),差的是"编辑器手感"和"工程附件"。**
---
## 二、逐项对照
### 2.1 编辑体验(差距最明显,也最容易补)
| 能力 | GoLand | MyGoland | 说明 |
|---|---|---|---|
| 代码折叠 | ✅ | ❌ | 框架已内置 `Fold/FoldImports/ToggleFold/FoldAll`,**只是没接命令** |
| 内联提示(参数名/类型) | ✅ | ❌ | 框架有 `SetInlays`,gopls 有 `textDocument/inlayHint`,客户端缺实现 |
| 文件内查找替换 | ✅ | ❌ | 编辑器有 `Find/FindMatches/RenderFindBar`,缺一个查找条 UI |
| 实时模板(for/err/iferr) | ✅ | ❌ | 需自建片段系统 |
| 多光标 / 列选择 | ✅ | ❓ | 编辑器有 `Selections()` 多选 API,未接 UI |
| 注释切换 | ✅ | ✅ | `Ctrl+/` |
| 格式化 | ✅ | ✅ | 保存时 gopls 格式化 |
| 自动 import | ✅ | ✅ | gopls 代码动作(Alt+Enter) |
| 括号匹配/自动缩进 | ✅ | ✅ | 编辑器内置 |
| 书签 | ✅ | ❌ | 低优先 |
| 本地历史(Local History) | ✅ | ❌ | 我们只有 git;GoLand 有"改动即存档" |
| 拼写检查 | ✅ | ❌ | 不需要 |
### 2.2 导航
| 能力 | GoLand | MyGoland |
|---|---|---|
| 跳转定义 | ✅ F12 | ✅ F12 / Ctrl+Click |
| 查找引用 | ✅ Shift+F2 | ✅ Shift+F2 |
| 文件名搜索 | ✅ | ✅ Ctrl+P |
| **全局符号搜索** | ✅ Ctrl+Alt+Shift+N | ❌(只有当前文件大纲) |
| 动作搜索 | ✅ | ✅ Ctrl+Shift+P(含代码动作) |
| 最近文件 | ✅ Ctrl+E | ⚠️ 有「最近项目」,没有「最近文件」快速切换 |
| 结构视图 | ✅ | ✅ 大纲面板 |
| 面包屑 | ✅ | ✅ |
| 跳转到行 | ✅ Ctrl+G | ❌ |
| 问题间跳转 | ✅ F2 | ⚠️ 问题面板点击,无「下一个问题」键 |
### 2.3 重构
GoLand 有一整套自有实现;我们靠 gopls 的 code action,**能力上接近,入口上落后**。
| 重构 | GoLand 键 | MyGoland |
|---|---|---|
| 重命名符号 | Shift+F6 | ✅ F2 |
| 提取函数/变量/常量 | Ctrl+Alt+M/V/C | ⚠️ gopls 已提供(Alt+Enter 里能搜到「Extract function」),未做专门入口 |
| 内联 | Ctrl+Alt+N | ⚠️ 同上(refactor.inline) |
| 更改签名 | Ctrl+F6 | ❌ gopls 不支持 |
| 移动/安全删除 | F6/Alt+Delete | ⚠️ 文件级能移动/删除;符号级无 |
| 重命名结构体字段同步 JSON tag | ✅ | ❌ gopls 的行为取决于版本 |
**判断**:真正缺的只有「更改签名」。其余是**入口问题**——把 gopls 返回的 refactor.* 动作按类别单独列出来即可。
### 2.4 调试
| 能力 | GoLand | MyGoland |
|---|---|---|
| 断点(条件/禁用/列表) | ✅ | ✅ |
| 变量树(可展开结构体) | ✅ | ✅(`children`/`expanded` 按引用号展开) |
| 调用栈跳转 | ✅ | ✅ |
| 表达式求值 | ✅ | ✅ |
| Goroutine 视图 | ✅ | ❌ |
| Watch 表达式 | ✅ | ❌ |
| Attach 到进程 | ✅ | ❌(只支持 launch) |
| 断点组/静音全部 | ✅ | ❌(有单条禁用) |
| 内联变量值(调试时行尾显示) | ✅ | ❌ |
### 2.5 测试(差距仅次于 VCS)
| 能力 | GoLand | MyGoland |
|---|---|---|
| 运行测试 | ✅ 图形化 | ⚠️ `go test ./...` 文本输出到面板 |
| 单测/单函数运行 | ✅ 行号旁图标 | ❌ |
| 结果树(包→测试→子测试) | ✅ | ❌ |
| 覆盖率(行级红绿) | ✅ | ❌ |
| Race 检测开关 | ✅ | ❌(得手敲参数) |
| Benchmark | ✅ | ❌ |
### 2.6 版本控制
| 能力 | GoLand | MyGoland |
|---|---|---|
| 文件状态着色 | ✅ | ✅ |
| 提交(含消息) | ✅ 完整提交面板 | ⚠️ 输入框 + `add -A && commit` |
| **Diff 查看** | ✅ 并排 + 行内 | ❌(框架自带 `editor.DiffView`,成本比预想低) |
| 提交历史 / 日志 | ✅ | ❌ |
| 行级 blame | ✅ | ❌ |
| 分支管理(切换/新建/合并) | ✅ | ❌ |
| 冲突解决 | ✅ 三方合并 | ❌ |
| 行级/文件级暂存 | ✅ | ❌(我们是 `add -A` 全量) |
| Stash / Shelve | ✅ | ❌ |
### 2.7 工程与生态(这里不建议追)
| 能力 | GoLand | 判断 |
|---|---|---|
| 数据库 / SQL 控制台 | ✅ 完整 DataGrip 内核 | **不做**:等于重写一个产品 |
| Docker / K8s | ✅ | **不做**:终端能跑 `docker` 就够 |
| Proto / gRPC | ✅ | **暂不做**:需要 protoc 集成,收益窄 |
| go.mod 依赖图 | ✅ | 可做轻量版(列出依赖 + 升级提示),优先级低 |
| 远程开发(SSH/WSL/容器) | ✅ | **不做**:架构级改造(前后端分离) |
| 插件系统 | ✅ 上千插件 | **不做**:自用产品没有生态诉求 |
| AI 补全 / AI 助手 | ✅ | **另开项目**:属于模型能力,不属于 IDE |
---
## 三、值得做的 8 项(按 ROI 排序)
| # | 项目 | 收益 | 成本 | 依赖的现成能力 |
|---|---|---|---|---|
| 1 | **代码折叠** | 高(长文件必备) | **0.5 天** | 框架 `Fold/FoldAll/ToggleFold` 现成 |
| 2 | **文件内查找替换** | 高(每天用几十次) | **1 天** | `Find/FindMatches/RenderFindBar` 现成 |
| 3 | **内联提示(参数名/类型)** | 高(读代码快很多) | **1–2 天** | `SetInlays` + gopls `inlayHint` |
| 4 | **全局符号搜索** | 中高 | **1 天** | gopls `workspace/symbol` + 复用命令面板 |
| 5 | **测试结果树 + 单测运行** | 高 | **3 天** | `go test -json` 解析 + 面板树 |
| 6 | **覆盖率(行级红绿)** | 中高 | **2 天**(在 5 之上) | `-coverprofile` + `LineBackgrounds` |
| 7 | **Git diff 查看** | 高 | **1.5 天** | 框架 `editor.DiffView` 现成 + `git diff` |
| 8 | **Git 历史 / 行级 blame** | 中 | **2 天** | `git log --follow` / `git blame -L` |
前 4 项加起来约 **3.5 天**,能把「编辑手感」拉到接近 GoLand 的水平——这是投入产出比最高的部分。
---
## 四、明确不建议做(附理由)
| 项目 | 理由 |
|---|---|
| 数据库 / SQL 工具 | 工作量相当于再造 DataGrip,而你的场景里 Navicat/SSMS 已经够用 |
| Kubernetes / Docker 深度集成 | 我们用终端跑 `kubectl`/`docker` 没有任何损失,做 UI 反而是负债 |
| 远程开发 | 需要前后端分离架构(客户端 + 服务端 IDE),是产品级重构,不是功能 |
| 插件系统 | 没有第三方生态就只是给自己加抽象层 |
| 完整的重构集(改签名/安全删除) | gopls 不支持的部分要么做不到位,要么成本极高;能用 gopls 的已经能用 |
| AI 补全 | 属于模型与推理成本问题,与本项目解耦更合适 |
| 拼写检查 / 代码风格强约束 | Go 生态已有 `gofmt`/`golangci-lint`,IDE 侧重复造轮子价值低 |
---
## 五、MyGoland 反而更强的地方(客观记录)
| 维度 | GoLand | MyGoland |
|---|---|---|
| 冷启动 | 10–20 秒(含索引) | **约 1 秒** |
| 安装体积 | 800 MB+(含 JVM) | **15 MB 单文件** |
| 索引等待 | 首次打开要建索引 | 无索引,打开即用 |
| 可改造性 | 只能写插件 | 源码在手,想改就改 |
| 部署 | 需要安装 + 授权 | 拷一个 exe 就能跑 |
| 老机器(Win7 工控机) | 基本跑不动 | 可跑(本机验证过 Win10,Win7 待验证) |
最后一条对你有现实意义:如果将来要把「现场看日志/改配置」的工具发到搅拌站工控机上,GoLand 这条路走不通。
---
## 六、建议路线
### 阶段一:编辑手感(约 3.5 天,建议立刻做)
1. 代码折叠(0.5 天)
2. 文件内查找替换(1 天)
3. 内联提示(1–2 天)
4. 全局符号搜索(1 天)
做完这四项,日常写代码的「别扭感」基本消失。
### 阶段二:工程闭环(约 6.5 天)
5. 测试结果树 + 单测运行(3 天)
6. 覆盖率(2 天)
7. Git diff 查看(1.5 天)
做完之后,「改代码 → 跑测试 → 看差异 → 提交」这条链路不必再切到终端。
### 阶段三:可选增强(按需)
- Git 历史 / blame(2 天)
- 代码模板(2 天)
- 书签、跳转到行、下一个问题(1 天)
- 调试增强:watch 表达式、goroutine 视图(3 天)
---
## 七、如果只能做三件事
1. **查找替换**——没有它,每次搜索都要靠全局搜索,效率损失最直接
2. **测试结果树**——现在跑测试只能看一坨文本,失败定位全靠肉眼
3. **Git diff**——框架已经给了 DiffView,不接上是浪费
这三项大约 5 天,能把「日常够用」变成「日常顺手」。
Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 660 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 517 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 659 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 625 KiB

+121
View File
@@ -0,0 +1,121 @@
# MyGoland Logo 素材清单
Gopher 抱齿轮标识,基于 Go 官方 Gopher 造型(Renée French 设计,CC BY 3.0)。
主色:身体 `#62CBDB`、齿圈 `#324F60`、辐板 `#4A6C7E`、轮毂 `#1B3A49`、米色 `#F1C99B`。
## 图标 / 应用
| 文件 | 用途 |
|---|---|
| `mygoland.ico` | Windows 应用图标,含 16/24/32/48/64/128/256 七种尺寸 |
| `favicon.ico` | 网页 favicon,含 16/32/48 |
| `appicon.png` | Wails 构建图标(512×512,透明底) |
| `appicon-1024.png` | Wails / macOS 用大图(1024×1024,透明底) |
| `icon-16.png` `icon-32.png` `icon-48.png` `icon-96.png` | 透明底小图标,托盘、任务栏、列表页 |
| `icon-180-white.png` | apple-touch-icon(白底,iOS 不接受透明) |
| `icon-192-white.png` `icon-512-white.png` | PWA / Android 图标(白底) |
## 通用位图
| 文件 | 用途 |
|---|---|
| `mygoland-logo-1024.png` | 白底主图,文档、README、PPT |
| `mygoland-logo-{512,256,128,64,32}.png` | 白底多尺寸 |
| `mygoland-logo-transparent-1024.png` | 透明底主图,叠任意背景 |
| `mygoland-logo-transparent-{512,256,128,64,32}.png` | 透明底多尺寸 |
## 深色主题
| 文件 | 用途 |
|---|---|
| `mygoland-logo-dark-512.png` | 深色圆角底版本(底色 `#12161A`),深色 README / 深色 UI |
| `mygoland-logo-dark-256.png` `mygoland-logo-dark-128.png` | 同上小尺寸 |
## 单色 / 印刷
| 文件 | 用途 |
|---|---|
| `mygoland-logo-mono-black.png` | 黑色线稿,透明底。单色印刷、热敏 / 激光雕刻 |
| `mygoland-logo-mono-black-white.png` | 黑色线稿,白底。直接贴进只能显示白底的文档 |
| `mygoland-logo-mono-white.png` | 白色线稿,透明底。深色背景、深色界面反白用 |
| `mygoland-logo-mono-black-{512,256}.png` | 线稿多尺寸 |
单色线稿只保留黑色描边,填充全部透明,笔尖/刀刃路径清晰,可直接用于印章、雕刻、绣标。
## 归档
`v1-simple-gear/` 是齿轮简化版(纯深色平涂,无减重孔),在小尺寸下对比度更好,保留备用。
## 使用约定
- 最小使用尺寸:彩色版 64px,单色线稿版 48px。低于此尺寸请用 `icon-16.png` / `icon-32.png`。
- 图标四周已留 8% 安全边距,不要再自行裁切贴边。
- 深色背景上优先用 `mygoland-logo-transparent-*`,不要用白底版。
- 标识不要拉伸变形,不要给图形加描边、阴影或外发光。
## 关于矢量源文件
当前所有素材均为 1024×1024 位图导出。曾尝试用自动描摹生成 SVG,但位图边缘的抗锯齿噪点会被放大成毛刺(黑色描边断裂、齿轮糊成黑块),达不到生产质量,已放弃该路线。
若后续需要真 SVG,建议按现有造型做一次人工矢量化重绘:齿轮用正多边形阵列构造(保证齿距严格相等),人物用椭圆与圆角矩形拼装。这个工作用矢量工具约 1–2 小时,而且能顺带产出真正的单色剪影和 16px 优化版。
---
# 项目内接入
标识已经接进 MyGoland 应用代码,不再只是素材文件。
## 资源落位
| 位置 | 内容 | 用途 |
|---|---|---|
| `internal/app/assets/logo.png` | 透明底 256×256 | 欢迎页、关于页里的标识 |
| `internal/app/assets/icon.png` | 浅色圆角卡片 256×256 | 窗口标题栏、任务栏图标 |
| `resources/icon.png` | 浅色圆角卡片 1024×1024 | mygo 打包用的应用图标 |
| `docs/logo/final/mygoland-app.ico` | 卡片版 16–256 七尺寸 | 生成 exe 资源用 |
| `rsrc_windows_amd64.syso` | 由上面的 ico 生成 | 链接进 exe,决定文件图标 |
## 代码接入点
| 文件 | 改动 |
|---|---|
| `internal/app/logo.go` | `go:embed` 内嵌两张图,启动时解码一次;提供 `logoCard()` 画浅色底板上的标识 |
| `internal/app/app.go` | `Start()` 里 `a.win.SetIcon(iconPNG)`;`App` 结构体新增 `aboutWin` |
| `internal/app/view.go` | `welcomeView()` 顶部加 104px 标识卡片,副标题带版本号 |
| `internal/app/about.go` | 新增「关于 MyGoland」窗口(400×380 固定尺寸) |
| `internal/app/menu.go` | 新增「帮助 → 关于 MyGoland」菜单项 |
## 为什么准备两套图片
界面里不能用透明底图片直接贴:主题底色是 `#12161A`,齿轮的 `#324F60` 和黑色描边会一起糊进背景,轮廓读不出来。所以:
- **界面**用透明图,由 `logoCard()` 自己画一块 `#E9EFF5` 的圆角底板。
- **系统图标**(任务栏 / exe 文件)不能自己画底板,所以单独出一张自带浅色圆角底的 `icon.png`。
## 构建
```bash
go build -o MyGoland.exe .
```
图标已经通过 `rsrc_windows_amd64.syso` 链接进 exe,`go build` 会自动带上,不需要额外参数。
换了 ico 之后要重新生成 syso:
```bash
go install github.com/akavel/rsrc@latest
rsrc -ico docs/logo/final/mygoland-app.ico -o rsrc_windows_amd64.syso
go build -o MyGoland.exe .
```
验证 exe 是否带图标(应能看到 `RT_ICON` 和 `RT_GROUP_ICON`):
```bash
python -c "import pefile; p=pefile.PE('MyGoland.exe'); print([e.id for e in p.DIRECTORY_ENTRY_RESOURCE.entries])"
```
`mygo.json` 已写好打包元数据(name / identifier / version / icon),装了 mygo CLI 之后可以用 `mygo build` 出安装包。
## 许可
Gopher 造型来自 Renée French,CC BY 3.0。个人项目使用没问题;若对外分发,建议在「关于」里加一行署名,或改造造型规避商标风险。
Binary file not shown.

After

Width:  |  Height:  |  Size: 600 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 718 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 494 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 575 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

File diff suppressed because it is too large. Load diff
+51
View File
@@ -0,0 +1,51 @@
# 终端面板(2026-10-29)
## 1. 方案
用 mygo 官方 `plugins/terminal`(Ghostty 的 VT 模拟器 libghostty-vt),底部面板新增第 4 个页签「终端」,
`Alt+F12` 打开。外壳可切换:PowerShell / Git Bash / CMD。
| 外壳 | 查找顺序 |
|---|---|
| PowerShell | `pwsh.exe`(7.x)→ `%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe` |
| Git Bash | `%ProgramFiles%`、`%ProgramFiles(x86)%`、`%LOCALAPPDATA%` 下的 `Git\bin\bash.exe` → PATH 里的 `bash.exe` |
| CMD | `%ComSpec%` → `cmd.exe` |
- 工作目录 = 当前工作区根。
- 切换外壳会重启终端;切换工作区会重置终端,下次显示时落到新目录。
- 用 `ui.Segmented` 选外壳,右侧有「重启」按钮。
## 2. 关键坑:原生库
`terminal.New` 会 `Load()` 一个原生库 libghostty-vt(Windows 侧文件名 `ghostty-vt.dll`,2.07 MB)。
加载顺序:`$MYGO_GHOSTTY_VT` → 应用资源目录 → **exe 同目录** → 用户缓存。
本机实测:直连 GitHub Releases 下载 **120 秒超时**(国内网络)。解决方式:
1. 通过镜像 `https://ghfast.top/<原始地址>` 下载;
2. 校验 SHA-256 与 `plugins/terminal/mygo-plugin.json` 声明一致
(windows-amd64:`53e8e2dd…65da41`);
3. 放 `resources/ghostty-vt.dll`,`build.cmd` 构建后自动复制到 exe 同目录。
因为 exe 同目录优先级高于缓存,程序不会再尝试联网下载。
## 3. 验证
| 项目 | 方法 | 结果 |
|---|---|---|
| 外壳检测 | `TestDetectShells` | 三个外壳都找到(本机为系统自带 5.1 版 + Git Bash 在 Program Files) |
| 终端真能跑 | `TestTerminalRunsCommand` | `cmd /c echo` 0.6 s 内出现在 `History()` |
| 端到端 | 启动应用并自动切到终端页签 | 日志 `terminal started: PowerShell`,外壳子进程存在 |
| 退出清理 | 强制结束应用后查进程 | 外壳进程随之消失,无残留 |
## 4. 已知限制
- 终端配色独立于编辑器主题,还没做同步(插件支持 `UseTheme`)。
- 单终端,没有分屏或多终端标签。
- 原生库缺失时给出下载指引而不是崩溃,但分发时仍需把 DLL 一起带上。
- 体积:exe 从 12.0 MB 增至 14.9 MB(终端插件),另需附带 2.07 MB DLL。
## 5. 给部署方的说明
把 `MyGoland.exe` 和 `ghostty-vt.dll` 放在同一目录即可。若 DLL 缺失,程序不会崩溃:
终端页签会显示提示,包含下载地址与两种修复方式(同目录放 DLL,或设置 `MYGO_GHOSTTY_VT`)。
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

Loaded 100 of 220 files, more files were not shown because too many files have changed in this diff. Show more