...
1exec cue eval imports.cue
2cmp stdout expect-stdout-cue
3
4-- frontmatter.toml --
5title = "Imports"
6description = ""
7
8-- text.md --
9A CUE file may import definitions from builtin or user-defined packages.
10A CUE file does not need to be part of a package to use imports.
11
12The example here shows the use of builtin packages.
13
14This code groups the imports into a parenthesized, "factored" import statement.
15
16You can also write multiple import statements, like:
17
18```
19import "encoding/json"
20import "math"
21```
22
23But it is good style to use the factored import statement.
24
25-- imports.cue --
26import (
27 "encoding/json"
28 "math"
29)
30
31data: json.Marshal({ a: math.Sqrt(7) })
32
33-- expect-stdout-cue --
34data: "{\"a\":2.6457513110645907}"
View as plain text