github.com/joomcode/cue@v0.4.4-0.20221111115225-539fe3512047/doc/tutorial/basics/8_packages/30_imports.txt (about)

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