GoLand Plugins

TinyGo for Tiny Applications. Discover a New Plugin for GoLand

If you need to create a Go application for a small device like a microcontroller, you would most likely use TinyGo. This is a new Go compiler that uses LLVM to optimize the code and generate machine code for the target architecture. 

Today we’d like to introduce the TinyGo plugin. It comes with several features, and we hope this new plugin will make writing code for devices with limited RAM easier and more enjoyable. 

This is a student project implemented as a part of our internship program. Two of our interns worked on it in Munich: Nikita Mironov from The Clausthal University of Technology and Oleksandr Voloshyn from The Technical University of Munich. We’d like to thank them for their hard work and effort.

JetBrains has winter and summer internship opportunities as well as year-round part-time positions in different locations. Open intern positions are regularly posted on our website

Since this project is still in its early stages of development, there may be some things that don’t run very smoothly. Your feedback would be greatly appreciated. 

Start new project

To use the TinyGo plugin, you will need the latest stable version of GoLand, which is 2021.1.2 as of this writing. 

We suppose that you’re familiar with TinyGo, but just in case, here are the installation instructions

After TinyGo is set up, install the plugin and click the New project button. You will see a new option on the left – TinyGo. Click on it and download the TinyGo SDK or point the IDE to the existing one on your machine. Also, choose the right target platform from the dropdown menu. Now click the Create button. If you want to open an existing project and adjust the configuration, go to Preferences/Settings | Go | TinyGo.   

To create a new .go file, right-click on the project folder. You will see a new option – TinyGo application – in the New section. It will suggest choosing a template. Let’s pick blinky1/blinky1.go – a “Hello, world” example in the TinyGo world. If you connect a board with an LED to the computer and flash this program to the board, it will make your LED blink.      

Completion and auto-imports

But let’s say you want to write the code yourself. You will discover that the TinyGo plugin supports code completion and the auto-import of packages. 

There are also code inspections configured specifically for TinyGo applications. To check them out, go to Preferences/Settings | Editor | Inspections.  

To flash the program, click on the green triangle in the gutter. There are several options. Choose Run TinyGo [name of your project]. You can adjust the configuration that was created by clicking on the same green triangle and choosing the Modify Run Configuration option. Also, the configuration can be adjusted from the dropdown menu in the top right-hand corner of the window. 

This is an open-source project, and its code is available on GitHub. You can also check out the TinyGo plugin page on JetBrains Marketplace.

That’s it! Bear in mind that work on this project is ongoing. Please contribute and help us make it better. As always, you can get in touch via Twitter or the Gophers Slack #goland channel. Share your feedback here in the comments or open an issue in our tracker.   

GoLand Plugins

TinyGo for Tiny Applications!探索适用于小程序开发的 GoLand 新插件

如果您需要为诸如微控制器等小型设备创建 Go 应用程序,那么您很可能会用到 TinyGo。 这是一款全新的 Go 编译器,它使用 LLVM 来针对目标架构优化代码以及生成机器代码。

 今天,我们要为您介绍 TinyGo 插件。 这款插件功能丰富,我们希望它能够使针对内存有限的设备编写代码的工作变得更加轻松愉快。 

这是一个作为我们实习计划的一部分而实现的学生项目。 该项目由我们位于慕尼黑的两名实习生完成:克劳斯塔尔工业大学的 Nikita Mironov 以及慕尼黑工业大学的 Oleksandr Voloshyn。 我们要感谢他们的勤奋工作和努力。

JetBrains 提供冬季和夏季实习机会,还有位于不同地点的全年兼职职位。 空缺的实习生职位会定期在我们的网站上发布。 

由于此项目尚处于早期开发阶段,因此可能会存在一些运行不太顺畅的情况。 我们十分期待您的反馈。

开始新项目

要使用 TinyGo 插件,您需要最新稳定版本的 GoLand,截至本文撰写时版本号为 2021.1.2。

相信您已对 TinyGo 有所了解,但以防万一,您可以参阅此安装说明。 

在 TinyGo 设置完成后,安装插件并点击 New project 按钮。 您将在左侧看到一个新选项 – TinyGo。 点击该选项并下载 TinyGo SDK 或将 IDE 指向您机器上的现有 SDK。 此外,从下拉菜单中选择正确的目标平台。 现在,点击 Create 按钮。 如果要打开现有项目并调整配置,请转到 Preferences/Settings | Go | TinyGo。    

要创建新的 .go 文件,请右键点击项目文件夹。 您将在 New 部分中看到一个新选项:TinyGo application。 它会建议选择一个模板。 让我们选择 blinky1/blinky1.go,它是 TinyGo 世界中的一个“Hello, world”示例。 如果您将带有 LED 的开发板连接到计算机并将此程序刷写到开发板上,它会使 LED 闪烁。         

补全和自动导入

现在假设您想自己编写代码。 您会发现 TinyGo 插件支持代码补全和自动导入软件包。 

还有专为 TinyGo 应用程序配置的代码检查。 要查看它们,请转到 Preferences/Settings | Editor | Inspections。  

要刷写程序,请点击间距内的绿色三角形。 其中包含多个选项。 选择 Run TinyGo [您的项目名称]。 您可以通过点击同一绿色三角形并选择 Modify Run Configuration 选项来调整已创建的配置。 此外,还可以从窗口右上角的下拉菜单中调整配置。 

这是一个开源项目,其代码托管在 GitHub 上。 您还可以在 JetBrains Marketplace 上查看 TinyGo 插件页面

就是这样! 请记住,此项目的工作仍在进行中。 期待您能贡献力量并帮助我们做得更好。 一如既往,您可以通过微博微信或 Gophers Slack #goland 频道与我们联系。 欢迎在评论区分享您的反馈,或者在我们的跟踪器中提交问题。