Go logo

GoLand

A cross-platform Go IDE with extended support for JavaScript, TypeScript, and databases

GoLand Plugins

TinyGo for Tiny Applications. Discover a New Plugin for GoLand

Read this post in other languages:

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.   

image description