An Arduino Nano 33 IoT needs pin names that match its board. A build tag lets TinyGo include the board’s pin-mapping file only for a matching build configuration. Go and TinyGo also use build tags to select files for operating systems and architectures. section 12.3.1
Listing 12.18 board_arduino_nano33.go: Exposed pins
//go:build arduino_nano33 #1 // This contains the pin mappings for the Arduino Nano33 IoT board. ... const ( D13 Pin = PA17 #2 LED = D13 #3 ) ...
The first line of the board file is `//go:build arduino_nano33`. When that tag is selected, the file supplies pin definitions such as `LED`. section 12.3.1
Use the constraint in the file, then select the configuration at build time:
- Put `//go:build {tag}` on the first line. A file whose required tag is not selected is ignored. section 12.3.1
- Pass tags with `-tags`: for example, `tinygo build --tags=cortex-m0plus,atsamd21g18a,sam,arduino_nano33 main.go`. The flag also works with test and run commands. section 12.3.1
- Express alternatives, combinations, or exclusions in the file constraint with `||`, `&&`, and `!`; `//go:build !windows` excludes Windows. section 12.4
Listing 12.23 targets/arduino-nano33.json: Target specifications
{
"inherits": ["atsamd21g18a"], #1
"build-tags": ["arduino_nano33"], #2
"flash-command": "bossac -i -e -w -v -R -U --port={port} #3
--offset=0x2000 {bin}", #3
"serial-port": ["acm:2341:8057", "acm:2341:0057"], #3
"flash-1200-bps-reset": "true" #3
}
A TinyGo target specification can supply build tags. The Arduino Nano 33 target lists `arduino_nano33`, allowing `tinygo build --target=arduino-nano33 main.go` instead of spelling out the tags. section 12.3.1
Keep the constraint beside the implementation it controls. For a board-specific program, check that the chosen tags—or target—include the pin mappings the program uses. section 12.3.1


