Repository navigation
feat: 新建 Go 项目可以选 GOROOT,Go 版本默认取所选 Go 的版本 - #7
Merged
Merged
Conversation
插件声明 go 工具定义:在 Homebrew、/usr/local/go、~/sdk/go* 等位置找 Go, 用 go version 读版本(需要 Core 6477e9a,宿主 1lck/Lithe-IDEA#1960)。 - 新建项目加入 GOROOT 字段(tool 类型,默认最新的 Go,创建后记为项目固定); Go 版本默认 ${field.goroot.version},没有找到 Go 时需要手动填写。 - 构建系统的 go 在 Go executable 设置之后交给工具定义解析,最后才用 PATH。 - 集成测试改为用插件的工具定义在本机找 Go,覆盖版本跟随、项目固定和用固定的 Go 构建;宿主固定到 fce5d46d3。
14 of 20 tasks
#1960 合入时没有带上 Core 6477e9a 的固定提交,改由 #1964 单独提交。 宿主固定到 b03dbf0c0(preview 1fc1e8b05 加上 Core 6477e9a),说明里的 宿主 PR 随之改为 #1964。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
#6 加进「新建项目」的 Go 只能手填 Go 版本,默认固定是 1.21,也不知道用户电脑上装的是哪个 Go。参照 GoLand 的新建项目:先选 GOROOT,Go 版本默认取所选 Go 的版本,项目以后就用这个 Go 构建和运行。
宿主已经有通用的
toolDefinitions(工具链发现、项目固定、构建解析)和生成器的tool字段,Java 插件的 JDK 就是这样接入的。Go 缺的是版本探针:go version以子命令开头,旧版 Core 不接受。Lithe-IDEA/Lithe-core-rust#52(main 6477e9a)放开了这一点,1lck/Lithe-IDEA#1964 把宿主的 Core 固定到 6477e9a(原本放在 #1960,但 #1960 合入时没有带上这个提交)。宿主和 Core 里没有任何 Go 专属代码。改动
plugin.json(版本仍是 0.1.0:0.1.0 还没发布,这些内容并进 0.1.0)requires加入toolDefinitions: 0。toolDefinitions[go]:bin/go(Windows 上是bin/go.exe)。go version读出,正则go version (?:devel )?go(\d+(?:\.\d+)*)。GOROOT环境变量PATH里的go/usr/local/gogo/*/libexec和go@*/*/libexec(Apple Silicon、Intel、Linuxbrew)/usr/lib/go、/usr/lib/go-*C:\Program Files\Go、Scoop~/sdk/go*(golang.org/dl)和~/go/go*homeVariable: GOROOT,并把${home}/bin加到PATH前面。buildSystems[go]的invocation.executables在selected(Go executable 设置)和path(PATH)之间插入{"kind": "toolchain", "toolchainID": "go"}:没有设置路径时,构建、检查、测试和运行用工具链解析出的 Go。projectGenerators[go-module]:goroot:tool类型,tool: go、minimumVersion: 1.21、pinAs: project、optional: true。默认选版本最新的 Go,创建后记为项目固定;没有找到 Go 时留空,不阻止创建。goVersion的默认值从1.21改为${field.goroot.version},说明也随之更新。没有 GOROOT 时 Go 版本为空、必填;宿主的高级选项在字段有问题时会自动展开(fix(desktop): 新建项目的高级设置箭头跟随展开状态,高级字段出现问题时自动展开 1lck/Lithe-IDEA#1960,已合入 preview)。e2e/host/desktop/internal/projectgen/go_integration_test.go:重写为五个测试:TestGoPluginToolDefinitionFindsTheLocalGo(新增):用插件的工具定义在本机找 Go(和新建项目一样,在空目录里跑toolchain.Load),确认找到PATH里那个 go 的 GOROOT,版本等于go env GOVERSION。机器上没有 go 时跳过。TestGoPluginGeneratesAModuleWithSampleCode:go.mod的go行等于所选 Go 的版本,生成计划带goroot的项目固定。toolchain.Resolve确认项目里的go解析到这个 GOROOT,并用解析出的go运行go vet和go run(GOTOOLCHAIN=local)。TestGoPluginGeneratesAnEmptyModuleWithoutAGoroot(原TestGoPluginGeneratesAnEmptyModule):没有 GOROOT 时手填 Go 版本也能创建,计划里没有项目固定。TestGoPluginGoVersionFollowsTheGoroot(新增):required)。TestGoPluginFormRejectsAModulePathWithSpaces:表单带上一个 GOROOT 安装,模块路径改合法后通过,Go 版本是这个 GOROOT 的版本。e2e/host/lithe-host.json:宿主固定到b03dbf0c0(feat(desktop): Core 固定到 6477e9a,工具定义的版本探针可以用子命令开头 1lck/Lithe-IDEA#1964 的分支提交:preview 1fc1e8b05 加上 Core 6477e9a),见“合入前”。README.md:PATH和GOROOT怎么设置。docs/releases/v0.1.0.md:新建项目和工具链的说明;兼容性改为需要 Core 6477e9a 或更新版本。docs/feature-matrix.md:go-project-generator:能力、证据、依赖的宿主能力、最近验证和验证方法(新增第 6 步:没有 Go 时的表单)都更新。go-support-plugin:记下构建的解析顺序和新证据,并注明它的端到端测试早于这次改动、没有重跑。日志
没有新的进程或日志来源。工具链发现(运行
go version探测版本)、项目固定的保存和构建时的解析,都是宿主已有的通用工具链流程,由宿主记录;插件不写日志。发布
这个 PR 不发版。
v0.1.0仍未发布,什么时候推标签、提交 Store 条目由维护者决定。合入前
feat(desktop): Core 固定到 6477e9a,工具定义的版本探针可以用子命令开头 1lck/Lithe-IDEA#1964 合入 preview 后,把
lithe-host.json的revision改成 preview 上的合入提交,再跑一次完整的node scripts/e2e-host.mjs。本 PR 没有在
b03dbf0c0上重跑internal/workbench的两个端到端测试(TestOfficialGoPluginBuildsAndServesAModule、TestOfficialGoPluginDebugsAModuleWithDelve),而构建的go改为先走工具链解析。合入前要跑:验证
fce5d46d3(#1960 分支上的 Core 固定提交)和b03dbf0c0(#1964)里分别复制本仓库的go_integration_test.go,运行LITHE_PLUGIN_GO_DIR=<插件目录> scripts/desktop/desktop-go.sh test ./internal/projectgen/ -run '^TestGoPlugin' -count=1 -v/opt/homebrew/Cellar/go/1.27.4/libexec,生成的go.mod是go 1.27.4pluginhost.Validate(ctx, core.NewClient(), manifest, pluginhost.Declared())(测试已删除)plugin.jsonnode scripts/package.mjsdist/go-support-0.1.0-darwin.zip,SHA-2569ce7fe0e0c7fca55824d82a7fab61f9e6d643a97cb5a9e168fddf6a6b235a36avalidate-index.mjs的readPackageManifests+checkManifest)node scripts/e2e-host.mjs(internal/workbench构建和调试端到端测试)