Skip to main content
os() returns the name of the operating system on which Errand is running. Common values are "linux", "darwin", and "windows".

Signature

os() string

Example

Build platform-specific binaries and package them with the correct archive format:
variable "version" {
  type = string
}

computed "current_os" {
  description = "Current operating system"
  expression  = os()
}

computed "archive_ext" {
  description = "Platform-appropriate archive extension"
  expression  = computed.current_os == "windows" ? ".zip" : ".tar.gz"
}

task "package" {
  description = "Build and archive the binary for the current platform"
  commands = [
    "go build -o bin/app${computed.current_os == "windows" ? ".exe" : ""} ./cmd/app",
    "tar -czf app-${var.version}-${computed.current_os}.tar.gz bin/",
  ]
}

Notes

  • Common values: linux, darwin (macOS), windows, freebsd.
  • To detect the CPU architecture, use arch.