Getting started
Meta: keep this page small. The promise is "running code in 5 minutes." Anything that risks shaving 30 seconds off should be moved out. Show one Dagger example and one plain-GraphQL example so readers see the dual nature early.
Install
go install github.com/vito/dang/cmd/dang@latest(orgo install ./cmd/dangfrom a checkout)- editor support: VS Code, Zed, Neovim (see
editors/)
Hello, world
pub message(who: String!): String! {
`hello, ${who}`
}
print(message("world"))
dang hello.dangto run
No install needed to get a feel for it — this REPL runs Dang in your browser. State carries across entries, so define something and use it on the next line:
let greeting = "world"
Note: the browser REPL runs the core language only — no GraphQL imports, so GitHub, Dagger, and friends aren't available here. Install the CLI for those.
A first GraphQL call
Dang is designed for GraphQL APIs. To configure them, add a dang.toml:
[imports.GitHub]
endpoint = "https://api.github.com/graphql"
authorization = "Bearer ${GITHUB_TOKEN}"
Now you can run dang in REPL mode and explore the GitHub API:
$ export GITHUB_TOKEN="$(gh auth token)"
$ dang
Welcome to Dang REPL v0.1.0
Imports: GitHub, Dagger
Type :help for commands, Tab for completion, Alt+Enter for multiline, Ctrl+D to exit
dang> GitHub.user("vito").databaseId
=> 1880
Tip: To start an interactive schema browser, try :doc.
For a more elaborate GitHub demo, check out demos/github/main.dang.
A Dagger module in 10 lines
Dang is a natural fit for writing and consuming Dagger modules.
TODO: update this for Dagger 1.0
$ dagger init --sdk=dang
type Greeter {
pub message(target: String!): String! {
container
.from("ubuntu")
.withExec(["apt-get", "update", "-y"])
.withExec(["apt-get", "install", "-y", "cowsay"])
.withExec(["/usr/games/cowsay", `Hello, ${target}!`])
.stdout
}
}
- show the README's
Dang { source, build, test }example - explain what each line is doing in a sentence
Where next
- Language overview for the mental model
- GraphQL interop once you want to do real work
- Objects (
type) fortypedeclarations and methods (like the Dagger module above) - Modules and imports for splitting a program across files / directory modules