Modules & imports
Namespace import
Import an entire module under its name and access members with a dot:
import strings
import math
strings.upper("hello") // "HELLO"
math.sqrt(16.0) // 4.0
Named import
Import specific exports directly into scope:
import { abs, sqrt, PI } from "math"
println(sqrt(PI))
Sub-modules
Many modules are organized into sub-modules, reached with further dot access after importing the parent:
import time
import net
import thread
time.clock.now() // current time, RFC3339
net.tcp.connect("localhost", 8080)
thread.mutex.new()
Local modules
Any .goost file is a module. Import it by name (without the extension) to use
its top-level functions:
// math_utils.goost defines fn clamp(...)
import math_utils
println(math_utils.clamp(15, 0, 10)) // 10
Resolution order
When you import name, Langoost resolves it in this order:
- Standard-library modules — always checked first; stdlib names cannot be shadowed by local files.
- Filesystem — the directory of the script being run, then the current working directory.
Module cache
Compiled modules are cached by absolute path and modification time. After the first import, unchanged modules are served from cache as a map lookup — no recompilation. In long-running server mode this keeps imports effectively free.
Browse everything available out of the box in the standard library.