blob: c7176cd45b827fcfeb993e71717797f9f460194e [file] [log] [blame]
cue eval imports.cue
cmp stdout expect-stdout-cue
-- frontmatter.toml --
title = "Imports"
description = ""
-- text.md --
A CUE file may import definitions from builtin or user-defined packages.
A CUE file does not need to be part of a package to use imports.
The example here shows the use of builtin packages.
This code groups the imports into a parenthesized, "factored" import statement.
You can also write multiple import statements, like:
```
import "encoding/json"
import "math"
```
But it is good style to use the factored import statement.
-- imports.cue --
import (
"encoding/json"
"math"
)
data: json.Marshal({ a: math.Sqrt(7) })
-- expect-stdout-cue --
data: "{\"a\":2.6457513110645907}"