Skip to main content
join(separator, lists...) concatenates all elements of one or more lists into a single string, with separator placed between each element.

Signature

join(separator string, lists... list(string)) string

Example

Build a space-separated list of Go packages and pass it to a build command:
variable "packages" {
  description = "Go packages to build"
  type        = list(string)
  default     = ["./cmd/api", "./cmd/worker", "./cmd/scheduler"]
}

computed "package_list" {
  description = "Space-separated package list"
  expression  = join(" ", var.packages)
}

task "build" {
  description = "Build all packages"
  commands    = ["go build ${computed.package_list}"]
}
With the default value, the command becomes go build ./cmd/api ./cmd/worker ./cmd/scheduler.

Notes

  • If all lists are empty, join returns an empty string.
  • If the combined list has one element, no separator is added.
  • Multiple lists are concatenated before joining: join(", ", list1, list2) is equivalent to join(", ", concat(list1, list2)).