{"id":149490,"date":"2021-06-02T14:22:35","date_gmt":"2021-06-02T13:22:35","guid":{"rendered":"https:\/\/blog.jetbrains.com\/?post_type=go&#038;p=149490"},"modified":"2022-05-23T18:00:48","modified_gmt":"2022-05-23T17:00:48","slug":"tinygo-for-tiny-applications-discover-a-new-plugin-for-goland","status":"publish","type":"go","link":"https:\/\/blog.jetbrains.com\/zh-hans\/go\/2021\/06\/02\/tinygo-for-tiny-applications-discover-a-new-plugin-for-goland","title":{"rendered":"TinyGo for Tiny Applications. Discover a New Plugin for GoLand"},"content":{"rendered":"\n<p>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.&nbsp;<\/p>\n\n\n\n<p>Today we\u2019d like to introduce the <a href=\"https:\/\/plugins.jetbrains.com\/plugin\/16915-tinygo\" target=\"_blank\" rel=\"noopener\">TinyGo<\/a> 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.&nbsp;<\/p>\n\n\n\n<p>This is a student project implemented as a part of our <a href=\"https:\/\/www.jetbrains.com\/careers\/internships\/\" target=\"_blank\" rel=\"noopener\">internship program<\/a>. 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\u2019d like to thank them for their hard work and effort.<\/p>\n\n\n\n<p>JetBrains has winter and summer internship opportunities as well as year-round part-time positions in different locations. Open intern positions are regularly posted <a href=\"https:\/\/www.jetbrains.com\/careers\/jobs\/?role=Intern\" target=\"_blank\" rel=\"noopener\">on our website<\/a>.&nbsp;<\/p>\n\n\n\n<p>Since this project is still in its early stages of development, there may be some things that don\u2019t run very smoothly. Your feedback would be greatly appreciated.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Start new project<\/h2>\n\n\n\n<p>To use the TinyGo plugin, you will need the latest stable version of GoLand, which is 2021.1.2 as of this writing.&nbsp;<\/p>\n\n\n\n<p>We suppose that you&#8217;re familiar with TinyGo, but just in case, here are the <a href=\"https:\/\/tinygo.org\/getting-started\/\" target=\"_blank\" rel=\"noopener\">installation instructions<\/a>.&nbsp;<\/p>\n\n\n\n<p>After TinyGo is set up, <a href=\"https:\/\/plugins.jetbrains.com\/plugin\/16915-tinygo\" target=\"_blank\" rel=\"noopener\">install the plugin<\/a> and click the <em>New project<\/em> button. You will see a new option on the left \u2013 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 <em>Create<\/em> button. If you want to open an existing project and adjust the configuration, go to <em>Preferences\/Settings | Go | TinyGo<\/em>.&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"1500\" height=\"646\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2022\/05\/image-1.gif\" alt=\"\" class=\"wp-image-248751\"\/><\/figure>\n\n\n\n<p>To create a new <em>.go<\/em> file, right-click on the project folder. You will see a new option \u2013 <em>TinyGo application<\/em> \u2013 in the <em>New<\/em> section. It will suggest choosing a template. Let\u2019s pick <em>blinky1\/blinky1.go<\/em> \u2013 a &#8220;Hello, world&#8221; 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.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"1500\" height=\"791\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2022\/05\/create-new-tiny-file.gif\" alt=\"\" class=\"wp-image-248878\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Completion and auto-imports<\/h2>\n\n\n\n<p>But let\u2019s say you want to write the code yourself. You will discover that the <em>TinyGo<\/em> plugin supports code completion and the auto-import of packages.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"1500\" height=\"601\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2022\/05\/image-2.gif\" alt=\"\" class=\"wp-image-248763\"\/><\/figure>\n\n\n\n<p>There are also code inspections configured specifically for TinyGo applications. To check them out, go to <em>Preferences\/Settings | Editor | Inspections<\/em>.&nbsp;&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"1600\" height=\"746\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2022\/05\/image-28.png\" alt=\"\" class=\"wp-image-248774\"\/><\/figure>\n\n\n\n<p>To flash the program, click on the green triangle in the gutter. There are several options. Choose <em>Run TinyGo [name of your project<\/em>]. You can adjust the configuration that was created by clicking on the same green triangle and choosing the <em>Modify Run Configuration<\/em> option. Also, the configuration can be adjusted from the dropdown menu in the top right-hand corner of the window.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"1500\" height=\"1055\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2022\/05\/image-4.gif\" alt=\"\" class=\"wp-image-248808\"\/><\/figure>\n\n\n\n<p>This is an open-source project, and its code is available <a href=\"https:\/\/github.com\/JetBrains\/tinygo-plugin\" target=\"_blank\" rel=\"noopener\">on GitHub<\/a>. You can also check out the TinyGo plugin <a href=\"https:\/\/plugins.jetbrains.com\/plugin\/16915-tinygo\" target=\"_blank\" rel=\"noopener\">page<\/a> on JetBrains Marketplace.<\/p>\n\n\n\n<p>That\u2019s 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 <a href=\"https:\/\/twitter.com\/GoLandIDE\" target=\"_blank\" rel=\"noopener\">Twitter<\/a> or the <a href=\"https:\/\/invite.slack.golangbridge.org\/\" target=\"_blank\" rel=\"noopener\">Gophers Slack<\/a> #goland channel. Share your feedback here in the comments or open an issue in <a href=\"https:\/\/youtrack.jetbrains.com\/issues\/GO?_gl=1*1ryja4i*_ga*MTMzMTM3NzQ1MS4xNjIxOTM2MTky*_ga_0WQ2ZF5VGT*MTYyMjQ3MTM1Ny4zOS4xLjE2MjI0NzE0NDkuMA..&amp;_ga=2.61428393.463726163.1622398163-1331377451.1621936192&amp;_gac=1.49805012.1621529532.Cj0KCQjwkZiFBhD9ARIsAGxFX8CLxXvfJzlAlF42EN3ry-0foEM5GdeLKEOzRSUXC2Dj1LK8EQNhW5UaAoKBEALw_wcB\" target=\"_blank\" rel=\"noopener\">our tracker<\/a>.&nbsp;&nbsp;&nbsp;<\/p>\n","protected":false},"author":1254,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","categories":[4221,1065],"tags":[41],"cross-post-tag":[],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/go\/149490"}],"collection":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/go"}],"about":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/types\/go"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/users\/1254"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/comments?post=149490"}],"version-history":[{"count":6,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/go\/149490\/revisions"}],"predecessor-version":[{"id":248901,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/go\/149490\/revisions\/248901"}],"wp:attachment":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/media?parent=149490"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/categories?post=149490"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/tags?post=149490"},{"taxonomy":"cross-post-tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/cross-post-tag?post=149490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}