Documentation
¶
Overview ¶
Package tinygo reads target and port metadata from the TinyGo command-line interface. Commands are executed directly rather than through a shell, and command-derived names are constrained before they reach generated tasks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanFlash ¶
CanFlash reports whether TinyGo provides either a flash method or a custom flash command for the target.
func PortRelevant ¶
PortRelevant reports whether flashing the target may require an explicit serial port. Mass-storage targets intentionally return false even if their metadata also advertises reset behavior.
func ValidatePort ¶
ValidatePort accepts an empty value for automatic port detection. Non-empty values are restricted to characters used by Unix device paths and Windows COM ports so generated task arguments cannot smuggle shell syntax.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client runs a specific TinyGo executable from a project root. Target metadata is cached per client and may be queried concurrently.
func New ¶
New returns a client that invokes executable with root as its working directory. It does not verify either path until a command is run.
func (*Client) Info ¶
Info returns complete metadata for target. Successful results are cached, so callers must treat the returned Info as read-only; cancellation affects only cache misses that start a subprocess.
func (*Client) Ports ¶
Ports returns devices reported by TinyGo, sorted by port name. An empty list is valid; malformed or unsafe port names fail the entire query.
type Info ¶
type Info struct {
// Target contains the flashing fields from TinyGo's resolved target spec.
Target struct {
// FlashMethod selects TinyGo's built-in flashing implementation.
FlashMethod string `json:"flash-method"`
// FlashCommand is a target-provided external flashing command template.
FlashCommand string `json:"flash-command"`
// PortReset records whether TinyGo performs a 1200-baud port reset.
PortReset string `json:"flash-1200-bps-reset"`
} `json:"target"`
// GOROOT is TinyGo's generated Go root for this target and TinyGo version.
GOROOT string `json:"goroot"`
// GOOS and GOARCH select the target platform presented to Go tooling.
GOOS string `json:"goos"`
GOARCH string `json:"goarch"`
// GOARM and GOMIPS contain optional architecture tuning values.
GOARM string `json:"goarm"`
GOMIPS string `json:"gomips"`
// BuildTags are the complete target tags required for package discovery.
BuildTags []string `json:"build_tags"`
}
Info is the subset of `tinygo info -json` required to configure gopls and decide whether a target supports flashing or needs a serial port.
type Port ¶
type Port struct {
// Name is the device path or COM port accepted by TinyGo's -port flag.
Name string
// ID is the hardware identifier reported by TinyGo.
ID string
// Boards is TinyGo's optional human-readable board match.
Boards string
}
Port describes one device reported by `tinygo ports`.