GoLand 2020.1 稳定版已发布,GoLand 2020.1 除了改进对 Go Modules 的支持,在代码编辑方面也带来了许多对开发者友好的功能,以及为自动补全代码功能增加新的类型。另外在代码检查和快速修复方面也有改进。
下载地址 https://www.jetbrains.com/go/download
官方表示这是更快、更智能的一个版本,继续看看有哪些亮点。

改进对 Go Modules 的支持
- 配置环境变量更方便:现在可以使用 Go Modules 项目模板配置环境变量的默认值。只需单击“Environment”表单中的“Browse”图标即可打开新的“环境变量”对话框。

- 改进对 go.mod 文件的支持:支持对关键字(
go
、 module
、 require
、 replace
和 exclude
)、依赖项名称以及用本地路径替换进行自动补全

- 重构 Rename 和 Move 功能:当重命名或移动‘replace’语句引用的目录时,GoLand 将相应地更改 go.mod 文件中的路径

- 通过 Project View 调用 Find Usages.,以浏览 go.mod 文件中特定目录的路径

Go 1.14 支持
- 支持重叠接口:Go 1.14 添加了对嵌入重叠接口的支持,GoLand 2020.1 也已支持此功能。当使用重叠接口描述类型的不同方面时,GoLand 不会将这些方面的重复方法报告为错误。

- 自动 vendoring 模式:如果模块根目录包含 vendor 目录,则会在 Go 1.14 中自动启用 vendoring 模式。对于 GoLand 2020.1,将会为 Go 1.13 及更早版本实现类似的行为。IDE 会自动将导入解析到 vendor/ 文件夹(如果模块中存在)。

代码编辑
- 编写多值返回函数的签名时,GoLand 2020.1 会在返回类型的逗号后面自动添加括号

- 当在字符串字面量中粘贴一些文本时,IDE 会使用双引号进行转义

智能代码补全 (⌥⇧Space or Ctrl+Shift+Space)
- 启用此功能,IDE 会建议一个指向结构体初始值设定项的指针

- 建议在断言和类型 switch 用例中首先使用兼容类型



基本代码补全 (⌃Space or Ctrl+Space)
- 为注释添加了基本代码补全特性,编写文档将更轻松。此功能可为当前包声明提供建议的命名,并为函数和方法提供建议的参数名称


调试器
- 添加分析器标签(profiler label),用于在调试或核心转储分析过程中更易区分 goroutine

- 添加对宏的支持,在 2020.1 中,可以将宏用作运行或调试应用程序的参数。 在 Run/Debug Configurations 对话框中,点击 Go Tool 中的 + 或 Program arguments 选项即可打开新的 Macros 对话框,其中会列出要使用的可用宏。此外,现在还可以将配置文件存储在项目中。 在 Run/Debug Configurations 对话框的顶部,选择 Store 作为项目文件选项

快速修复
- 按下 Alt+Enter 快捷键可马上将非格式化调用转为格式化调用

- Create variable 快速修复功能会显示预期的类型提示,方便使用者更好地输入正确的值

详情查看 https://www.jetbrains.com/go/whatsnew/
(文/开源中国)