Packages
Every StarLang file must begin with a package declaration. The package system is inspired by Go.
Syntax
The package name must be the first line in the file, before all other declarations.
package main
Files declared as package main are executable programs. These files require a fn main():void entry point.
A package main file without a main() function produces a compile error:
Library Packages
All packages other than package main are libraries. These files do not require a main() function.
package math
fn add(a:i32, b:i32):i32 {
return a + b
}
fn multiply(a:i32, b:i32):i32 {
return a * b
}
Library packages are loaded with import. See Modules for import syntax and namespacing rules.
star.mod
The star.mod manifest defines project metadata and dependencies (created by star-lang init):
See the star.mod reference for every directive (module, star, require, config) and how paths resolve.
Rules
| Rule | Description |
|---|---|
package is required |
Every .star file must start with package |
main is special |
Only package main files require fn main():void |
| Single package | Each file belongs to exactly one package |
| Naming | Package names must be lowercase, alphanumeric |