Modules
Do modules are named namespaces of values. A module can export functions, classes, constants, and other public bindings.
Importing Modules
Whole-Module Imports
Import a module by name:
Module names may be dotted:
When a dotted module name is imported without renaming, the local binding is the first component. That binding is a namespace object whose nested fields mirror the rest of the dotted name.
Conceptually, import build.tools binds a local build object, then inserts
the imported module at build.tools. A later import build.images extends the
same local build namespace instead of replacing it.
Renaming
Use module: alias to bind the imported module directly under a different
local name:
This also works with dotted module names:
Unlike import build.tools, this binds tools directly to the imported module.
It does not create a local build namespace object.
Importing Specific Items
Import selected public items from a module:
Renaming Imported Items
Rename individual imported items:
The left-hand side is the exported name in the module; the right-hand side is the local binding.
Combined Forms
The vertical form is useful when importing multiple modules at once:
Exporting with pub
Mark definitions as public with pub:
Only pub items are visible when a module is imported.
Module Resolution
Modules are resolved according to the host application. See the Shell
Guide for details on module path configuration for
dolang.