Skip to main content
arch() returns the CPU architecture of the machine running Errand. Common values are "amd64" and "arm64".

Signature

arch() string

Example

Build and name the release binary for the current platform, automatically picking up the right architecture:
variable "version" {
  type = string
}

computed "current_os" {
  expression = os()
}

computed "current_arch" {
  expression = arch()
}

computed "binary_name" {
  description = "Platform-specific binary filename"
  expression  = "app-${var.version}-${computed.current_os}-${computed.current_arch}"
}

task "build" {
  description = "Build the release binary for the current platform"
  commands = [
    "go build -o dist/${computed.binary_name} ./cmd/app",
    "echo 'Built: dist/${computed.binary_name}'",
  ]
}

task "checksum" {
  description = "Generate a checksum file for the binary"
  depends_on  = [task.build]
  commands = [
    "sha256sum dist/${computed.binary_name} > dist/${computed.binary_name}.sha256",
  ]
}
On an Apple Silicon Mac, computed.binary_name becomes app-1.4.2-darwin-arm64.

Notes

  • Common values: amd64 (x86-64), arm64 (64-bit ARM), arm, 386.
  • To detect the operating system, use os.