Go's standard library is a strong base for the backend and tooling side of mobile apps and for embedded Linux devices, but standard Go is not a language for writing app user interfaces or firmware for small microcontrollers. For mobile you use Go for APIs or share logic through gomobile, and for microcontrollers you use TinyGo.
This article explains what is realistic in each area, with working examples that use current Go.
| Target | Approach | Notes |
|---|---|---|
| Mobile app backend (REST, auth, sync) | Standard Go with net/http | The most common use |
| Shared logic inside Android or iOS apps | gomobile bind | Generates a Java, Kotlin, Objective-C or Swift API from Go packages |
| Full Go mobile UI | gomobile build with a UI toolkit such as Fyne | Limited and rarely used for production apps |
| Embedded Linux (Raspberry Pi, gateways) | Standard Go, cross-compiled | Static binaries, small deployment footprint |
| Microcontrollers | TinyGo | Subset of the standard library |
Most teams write the app in Kotlin, Swift or a cross-platform framework and use Go for everything behind it.
A mobile backend is a JSON API. The version below uses the Go 1.22 router with method and path patterns, sets timeouts on the server, and limits request bodies.
The original example called http.ListenAndServe without timeouts, which leaves the server open to slow-client attacks. Always set ReadHeaderTimeout at minimum. Mobile clients on poor networks also benefit from compact payloads, pagination and ETag headers.
gomobile bind compiles a Go package into an Android archive (.aar) or an iOS framework, so one implementation of validation, sync or cryptography serves both apps. Only a limited set of types can cross the boundary: basic types, strings, byte slices, structs and interfaces with supported fields.
The platform side then calls Core.slugify("Hello World") in Kotlin or Swift. The cost is a larger app binary and a build step that needs the Android NDK or Xcode.
On a Raspberry Pi or an industrial gateway you can use the full standard library. Cross-compile on your laptop and copy one static file to the device.
A typical agent reads a sensor file, stores state, and reports over the network:
DialContext gives the connection attempt a deadline, which matters on flaky cellular links. The path above exists on many Linux boards but not all, so handle the error as shown.
Standard Go needs an operating system and megabytes of RAM, so it does not run on small microcontrollers. TinyGo compiles Go for those boards with a smaller runtime. It supports a subset of the standard library and its own hardware packages, and you flash it with tinygo flash -target=<board>.
When a Linux device has a vendor C library you must use, cgo bridges to it, at the price of losing simple cross-compilation. Prefer pure-Go packages where they exist, and isolate cgo calls in one small package.
You can with gomobile and a toolkit such as Fyne, but the ecosystem is small. Most teams write the UI natively and share only business logic.
Standard Go does not. TinyGo supports many microcontroller boards, but not the whole standard library.
Yes. It starts fast, uses little memory, and the standard library has everything for an HTTP JSON API. Add a router, ORM or gRPC only when you need them.
A simple program is typically a few megabytes. Build with -ldflags="-s -w" to strip symbols, and compress with UPX only if you accept slower startup.
Use Go for mobile backends and shared logic through gomobile, and for embedded Linux through cross-compiled static binaries. Set server timeouts, use context for network calls, and choose TinyGo for microcontrollers.