Imports and packages
English | 日本語
Use @import for reusable code and shared constants. Local files use a relative path; installed packages use the alias in the project manifest.
Share settings without repeated preload declarations
Create settings.gd:
const TITLE := "Hello, world!"
const PORT := 8080Then use the file directly from app.gd:
@import "./settings"
func main():
print(settings.TITLE)
print(settings.PORT)
return 0gd app.gdThe filename provides the settings name. Neither .gd nor as settings is needed. This also avoids repeating const Settings = preload(...) in every consumer. Use a single file for a tiny one-off script; split settings only when they are shared or need their own responsibility.
Add a registry package
Browse the package catalog, then add the chosen package using its documented name and version range. An alias maps a short name to the dependency in gd.json:
gd add hello gd:@scope/hello@^1.0.0The command above illustrates the syntax; replace the package with one that exists in the catalog. Import an installed alias without quotes:
@import hello@import settings refers to a configured package alias; it is not a substitute for the local @import "./settings" spelling.
Keep dependency resolution reproducible
Commit gd.json and gd.lock. Run gd install --frozen when installation must follow the checked-in lock. Do not publish secrets, local credentials or temporary build data in a package. See the package manual for package metadata, publishing and dependency resolution.