TinyGo 0.42 - Recover Is Real

TinyGo 0.42 - Recover Is Real

Announcing TinyGo 0.42 with recoverable panics, Go 1.27 support, UEFI targets, and much more! By TinyGo Team | Tuesday, September 01, 2026

TinyGo 0.42 正式发布,它填补了 TinyGo 与“标准版”Go 之间最古老的差距之一。现在,运行时恐慌(Runtime panics)可以被恢复了。我们还增加了对 Go 1.27 的支持,以确保您能使用最新最棒的功能;同时升级到了 LLVM 22,并将 TinyGo 带入了一个全新的机器类别。


Go 1.27 and LLVM 22

Go 1.27 与 LLVM 22

TinyGo 0.42 adds support for Go version to 1.27, and the binaries we release with the compiler are built and tested with it. Generic methods, new in Go 1.27, are supported through an upgrade of golang.org/x/tools. We also moved our builds to LLVM 22, while keeping LLVM 19 and LLVM 20 working for people who build from a distribution package. See the Go compatibility matrix for the full picture of which TinyGo release works with which Go release.

TinyGo 0.42 增加了对 Go 1.27 版本的支持,我们随编译器发布的二进制文件均基于此版本构建和测试。通过升级 golang.org/x/tools,现在支持 Go 1.27 中新增的泛型方法。我们还将构建环境迁移到了 LLVM 22,同时保留了对 LLVM 19 和 LLVM 20 的支持,以方便那些从发行包进行构建的用户。请参阅 Go 兼容性矩阵,以全面了解各 TinyGo 版本与 Go 版本的对应关系。


Recover Is Real Now

恢复功能现已实现

Before this release, a nil pointer dereference or a divide by zero in a TinyGo program was the end of the story. Your program just stopped. That is no longer the case, thanks to the tireless efforts of our erstwhile maintainers. TinyGo 0.42 now makes runtime panics recoverable. Nil pointer dereferences, divide by zero, out of range slice and map operations, and channel panics all are handled through defer and recover the way you expect them to. On Windows we added a vectored exception handler to do the same job, and recover now works on riscv64 as well. The runtime knows which panics you can handle and the failures you cannot. Out of memory and other fatal errors stay unrecoverable, because there is nothing you can really do about it. This work reaches much further than error handling. The testing package now supports Goexit, SkipNow, and FailNow, so t.Skip and t.Fatal behave correctly. That single change unblocked a large number of standard library test suites. Take a look at the updated list of supported packages to see where things stand.

在此版本之前,TinyGo 程序中的空指针解引用或除以零错误意味着程序的终结,程序会直接停止。多亏了我们维护者们的不懈努力,这种情况已成为过去。TinyGo 0.42 现在使运行时恐慌变得可恢复。空指针解引用、除以零、切片和映射越界操作以及通道恐慌,现在都可以按照您预期的方式通过 deferrecover 进行处理。在 Windows 上,我们添加了向量化异常处理程序来实现相同的功能,并且 recover 现在也支持 riscv64 架构。运行时能够区分哪些恐慌是可以处理的,哪些是无法处理的。内存溢出和其他致命错误仍然不可恢复,因为这些情况确实无法通过代码修复。这项工作的影响远不止于错误处理。测试包现在支持 GoexitSkipNowFailNow,因此 t.Skipt.Fatal 的行为更加符合预期。这一项改动解锁了大量标准库测试套件。请查看更新后的支持包列表以了解当前进展。


TinyGo Boots Your Computer

TinyGo 启动您的计算机

This release adds a minimal UEFI target. You can now write a Go program, compile it with TinyGo, and run it as a UEFI application before any operating system starts. The target supports UEFI time and events, and it uses the tasks scheduler by default so goroutines work. This is early work, and there is a lot still to do. It is also a good demonstration of how far the compiler has come.

此版本增加了一个最小化的 UEFI 目标。您现在可以编写 Go 程序,使用 TinyGo 编译,并在任何操作系统启动之前将其作为 UEFI 应用程序运行。该目标支持 UEFI 时间和事件,并默认使用任务调度器,因此 goroutines 可以正常工作。这还处于早期阶段,仍有许多工作要做,但它很好地展示了编译器已经取得了多大的进步。


ESP32 Grows Up

ESP32 的成长

Espressif chips with their powerful wireless capabilities are some of the most popular around, and the ESP32 work that started in 0.41 has continued at full speed in this release. You probably still have a bunch of classic (old?) ESP32 boards in a drawer. Now you can pull them out and put them to work! We have interrupt support with a proper vector table, timer alarms, and SetInterrupt on GPIO pins for the original ESP32. It also gained an ADC driver, interrupt-driven UART receive, and flash XIP, which means execute in place. Larger programs now flash and run correctly. We have even added WiFi support, thanks to the espradio package. Speaking of wireless, we now also support Bluetooth on both the ESP32-C3 and ESP32-S3.

乐鑫(Espressif)芯片凭借其强大的无线功能成为最受欢迎的芯片之一。我们在 0.41 版本中启动的 ESP32 相关工作在此版本中得到了全速推进。您可能在抽屉里还放着一堆经典的(旧的?)ESP32 开发板,现在是时候把它们拿出来投入使用了!我们为原始 ESP32 提供了带有正确向量表的中断支持、定时器警报以及 GPIO 引脚上的 SetInterrupt 功能。它还获得了 ADC 驱动程序、中断驱动的 UART 接收以及 Flash XIP(原地执行)支持。现在,更大的程序可以正确烧录并运行了。得益于 espradio 包,我们甚至增加了 WiFi 支持。说到无线,我们现在还支持 ESP32-C3 和 ESP32-S3 上的蓝牙功能。


More Chips, More Boards

更多芯片,更多开发板

STM32 users also get a lot in this release. There is a new OTG FS USB driver for the F4 and F7 families, new support for the STM32H7 and the NUCLEO-H753ZI board, support for the STM32U031 chip, a selectable HSE crystal frequency, and fixes to UART transmission, baud rates, and interrupt handling. Other new hardware in this release: Puya PY32F microcontrollers, Pimoroni Blinky 2350 and Badger 2350, The ‘Plus’ variant of the Seeed Studio XIAO nRF52840, mGBA debugging support for the Game Boy Advance. USB support improved across the board. Endpoints are now registered dynamically, which brings bidirectional endpoint support to RP2, SAMD21, SAMD51, and nRF52840. Descriptors are generated dynamically, and there are new USBDevice.Attach and USBDevice.Detach methods. These are only some of the features and fixes included in the new release. See the CHANGELOG for the complete list.

STM32 用户在此版本中也收获颇丰。我们为 F4 和 F7 系列提供了新的 OTG FS USB 驱动程序,增加了对 STM32H7 和 NUCLEO-H753ZI 开发板的支持,支持 STM32U031 芯片,支持可选的 HSE 晶振频率,并修复了 UART 传输、波特率和中断处理方面的问题。此版本支持的其他新硬件包括:Puya PY32F 微控制器、Pimoroni Blinky 2350 和 Badger 2350、Seeed Studio XIAO nRF52840 的“Plus”变体,以及用于 Game Boy Advance 的 mGBA 调试支持。USB 支持得到了全面改进。端点现在可以动态注册,这为 RP2、SAMD21、SAMD51 和 nRF52840 带来了双向端点支持。描述符现在是动态生成的,并新增了 USBDevice.AttachUSBDevice.Detach 方法。以上仅是新版本中包含的部分功能和修复,完整列表请参阅 CHANGELOG。


Thank You, Fellow Humans!

感谢各位同仁!

As always, we must say special thanks to the humans who work behind the scenes on writing code, testing, creating documentation, and everything else it takes to make TinyGo real. You are appreciated!

一如既往,我们要特别感谢那些在幕后编写代码、进行测试、撰写文档以及为实现 TinyGo 而付出一切努力的人们。感谢你们的贡献!