Updated: 2025-08-21

Prerequisites

  1. Go complier

    You can download it from go.dev/dl.

  2. Git command

    To install git on Linux use the package manager provided by your Linux distribution (apt, pacman, rpm, …).

    Windows users may check the git for Windows website.

    The Mac users may use the git command provided by the Xcode commandline tools. Another way is to use the Homebrew package manager.

  3. Raspberry Pi Pico 2

    Alternatively you can use the Teensy 4.x or one of the supported STM32 boards.

  4. libusb-1.0

    It’s needed if you want to use our tool (egtool) to program your board. But you can use a hardware-specific tool instead, for example the picotool for Raspberry Pi Pico 2.

    Follow the instruction provided by gousb. Windows users should read this gousb note.

Embedded Go toolchain

The Embedded Go is released as as Go toolchain. All you need to get started is this toolchain, along with a simple utility for loading compiled programs onto your hardware.

  1. Install the Embedded Go toolchain.

    Make sure the $GOPATH/bin directory is in your PATH, as tools installed with the go install command will be placed here. If you didn’t set the GOPATH environment variable manually you can find its default value using the go env GOPATH command.

    Then install the Embedded Go toolchain using the following two commands:

    go install github.com/embeddedgo/dl/go-embedded@latest
    go1.24.5-embedded download
    
  2. Install egtool.

    go install github.com/embeddedgo/tools/egtool@latest
    

First program

As an example we will write a simple program for Raspberry Pi Pico 2. See also the similar descriptions for Teensy 4.x and STM32.

  1. Create a project directory containing the main.go file with your first Go program for RPi Pico 2.

    package main
    
    import (
    	"time"
    
    	"github.com/embeddedgo/pico/devboard/pico2/board/leds"
    )
    
    func main() {
    	for {
    		leds.User.Toggle()
    		time.Sleep(time.Second / 2)
    	}
    }
    
  2. Initialize your project.

    go mod init firstprog
    go mod tidy
    
  3. Copy the go.env file suitable for your board (here is one for Pico 2 and another one for a board with 16 MB flash).

  4. Compile your first program.

    export GOENV=go.env
    go build
    

    or

    GOENV=go.env go build
    

    or

    egtool build
    

    The last one is like GOENV=go.env go build but looks for the go.env file up the current module directory tree.

  5. Connect your Pico 2 to the computer in the BOOT mode (press the onboard button while connecting it to the USB).

  6. Load and run.

    egtool load
    

More information

Read Embedded Go blog.

Ask questions on the Embedded Go user group or reddit.