Questions tagged [tinygo]

TinyGo is a Go compiler that mainly targets embedded systems, by natively including libraries for a wide range of microcontrollers; and WASM. Always use the [go] tag along with this one, plus any applicable architecture tag.

TinyGo is a Go compiler that mainly targets embedded systems. It can output significantly smaller binaries compared with gc, the official Go compiler.

TinyGo is also a good compiler choice for targeting WASM. It provides comment directives like //export that help simplify development.

Useful links:

27 questions
5
votes
1 answer

Is it possible to make a Go binary smaller by compiling it with TinyGo?

The TinyGo Homepage says that it is designed for micro controllers (or MCU). I wonder if it is possible to use TinyGo to compile go into small binary for ARM/Linux system? Currently with UPX --best --lzma, my go code compiles to arm binary about…
xrfang
  • 1,754
  • 4
  • 18
  • 36
3
votes
1 answer

Golang to wasm compilation using tinygo. Execution using wasmtime

I have the following test code func main() { path, err := os.Getwd() log.Println(path, err) files, err := ioutil.ReadDir("/etc/dse") log.Println(files, err) } I compile it to wasm using tinygo build -target wasi -o list.wasm…
0x11111
  • 55
  • 3
3
votes
0 answers

How to use .witx definitions for Go code generation to use with TinyGo WebAssembly targeting WASI?

Is it possible to use .witx definition files for Go code generation to use with TinyGo's WebAssembly WASI (WebAssembly System Interface) support? Specifically, I want to create a Fastly Compute@Edge SDK for Go. These SDKs exist for JavaScript,…
Grokify
  • 15,092
  • 6
  • 60
  • 81
3
votes
1 answer

How to return object from tinygo webassembly target

I am using tinygo to generate a wasm for simple function: //export onInput func onInput() map[string]interface{} { return map[string]interface{}{ "key": 60, "remove": 1, } } Then I am using wasm target to build using tinygo,…
Leone
  • 3,258
  • 3
  • 22
  • 28
3
votes
1 answer

Envoy WASM failing to load due to missing import (using net/http Go module)

I'm trying to run my WASM Go filter to make an external HTTP call using the net/http module. Envoy fails to load the WASM code. Why is the import failing? Envoy/Istio version: istio/proxyv2:1.11.4 SDK version:…
enigma
  • 93
  • 1
  • 10
3
votes
1 answer

How to decode a JWT token with TinyGo

We have a JWT token that we need to decode, the issue is that we are using TinyGo and some libraries are not supported, How can it be done for TinyGo / core Go libraries which is already supported? I want to print the "name" value: I'm not able to…
JME
  • 881
  • 2
  • 11
  • 23
2
votes
0 answers

LLVM: If/Then branching in tiny-go LLVM

I'm using tinygo's LLVM bindings for Go (don't know if this is relevant) and I'm trying to implement If/Then branching without the else block. I've found this answer on stackoverflow: LLVM IRBuilder If-Then Codegen but it's using the C++ API and…
kamkow1
  • 467
  • 2
  • 8
2
votes
0 answers

How to perform Wasm host call from a Go guest?

How can one call custom Wasm host functions from a Go guest? I've looked at a few examples that show loading a self-contained witx/wat/wasm defined function, but haven't found an example for performing a host-defined call. Some examples I've looked…
Grokify
  • 15,092
  • 6
  • 60
  • 81
2
votes
1 answer

Installing TinyGo results in Command Line Tools (CLT) SDK folder names mismatch on macOS

When following the TinyGo Quick Install Guide for macOS I'm running into the following error: Error: The contents of the SDKs in your Command Line Tools (CLT) installation do not match the SDK folder names. % brew install tinygo ==> Installing…
Grokify
  • 15,092
  • 6
  • 60
  • 81
2
votes
0 answers

CompileError: WebAssembly.instantiate(): param count of 1055 exceeds internal limit of 1000 @+219

I'm using tinygo to compile my go project into a WebAssembly module, compile succeeds, but the browser shows below error: Instantiate wasm failed, error: CompileError: WebAssembly.instantiate(): param count of 1055 exceeds internal limit of 1000…
2
votes
2 answers

How do I control PWM output on Arduino using TinyGo

I'm trying to turn a motor using An Arduino ATMega2560 with code written in Go. There's an example here that uses TinyGo v0.14.1: https://create.arduino.cc/projecthub/alankrantas/tinygo-on-arduino-uno-an-introduction-6130f6 The example in essence…
Mor Blau
  • 420
  • 3
  • 15
2
votes
1 answer

Does go supports in MCU?

I have explored, does Go support on Micro Controller Unit. Got some info that is TinyGo. Have doubt is TinyGo equivalent to Golang which support in Linux.
1
vote
0 answers

SSD1306 - tinydraw: screen udates are very slow

I am trying to update an image on screen based on input (button pressed) the code look roughly like this: package main import ( "machine" "time" "image/color" "tinygo.org/x/drivers/ssd1306" "tinygo.org/x/tinydraw" ) func main() { …
NoLoop
  • 11
  • 1
1
vote
1 answer

How do I make --import-memory work for WASM compiled by tinygo

I am trying to compile WASM from go using tinygo for use in go-wasmer. I have the import memory working for AssemblyScript but when I use the flag for the WASM from go and try to create my instance I get this error Host env initialization error:…
1
vote
0 answers

Golang Bluetooth adapter.Scan stops by itself

I am using the tinygo-org/bluetooth package. When I run the scanner in the example, after a while the panic drops. I can't find the cause, does anyone have any idea what it could be? Thanks.
sercan
  • 182
  • 19
1
2