Go Interfaces Impl
面向 Go 语言的 VS Code 插件,用于查看当前 Go module 内具名类型与 interface 的实现关系。视觉呈现与交互参考 GoLand,在类型声明旁展示关联类型,并支持直接跳转。
为什么做这个?Go 语言优秀的接口隐式实现设计,让其能够在代码中被灵活地使用。但是隐式实现也带来了一定的可读性下降,对初学者来说可能不是特别友好。恰逢 AI 与 Vibe Coding 的蓬勃发展,本插件因此诞生。 主要功能
使用要求
插件使用 TypeScript 编写,通过 VS Code 公开语言接口复用官方 Go 扩展,不包含自有 Go 分析器,也不自行启动或管理 gopls。Go SDK 与语言服务由官方 Go 扩展负责。 使用方式打开 Go 文件后,插件自动查询可见类型声明的实现关系。具体类型上方显示 也可将光标放在类型名称处,通过命令面板执行:
显示上方关联名称需要启用 VS Code 的 配置
能力边界实现关系来自官方 Go 扩展的公开 definition、document symbol 和 implementation 接口。结果受语言服务返回的位置范围限制,不保证完整枚举 module 内的所有实现关系;没有可展示结果也不代表类型不存在实现关系。值与指针形式不分别显示,泛型、空接口及类型集合约束等类型存在查询限制。 测试来源过滤默认开启:类型声明文件以 查询以当前文件最近的 发布发布者 ID 为 第三方许可声明项目图标参考 Renee French 设计的 Go Gopher,原角色采用 CC BY 4.0 许可。本图使用 AI 重新绘制,加入接口括号与实现关系连线。 随扩展分发的 Tree-sitter 运行时与 Go 语法资源适用以下许可。 展开查看第三方许可全文@vscode/tree-sitter-wasm
Tree-sitterThe MIT License (MIT) Copyright (c) 2018-2024 Max Brunsfeld Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. tree-sitter-goThe MIT License (MIT) Copyright (c) 2014 Max Brunsfeld Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 许可证本项目遵循 MIT 许可证。 |