Modules and imports#

Meta: three audiences, in this order so each can stop reading early — single-file users (next section), directory-module users, then people wiring up dang.toml. import/shadowing/cycles follow.

A single file is a module#

A directory is also a module#

mymod/
  main.dang
  types.dang
  utils.dang

dang.toml#

dang.toml is discovered by walking up from the working directory (stopping at a .git boundary).

[imports.Dagger]
dagger = true

[imports.MyApi]
schema = "./schema.graphqls"
service = ["go", "run", "./server"]

[imports.Remote]
endpoint = "https://api.example.com/graphql"
authorization = "Bearer ${API_TOKEN}"

The endpoint, authorization, and headers values support ${VAR} environment expansion; $(...) command substitution is not supported.

import declarations#

import Dagger
import MyApi

Shadowing#

Ordering and cycles#

What a module exports#

Meta: dang.toml discovery walks up from the file's directory to the nearest .git boundary; the dang CLI runs the resolved module (see CLI reference).