Skip to main content
Forst extends familiar Go syntax with structural typing, constraints, and narrowing. Most .ft files look like Go. Where they differ, types behave like validated API schemas.

Aligned with Go

Ordinary Forst programs look like Go. A minimal executable is identical on both sides:
Use .ft files with the Forst CLI. The plain Go subset builds with go build. Forst extensions transpile to Go for production.

Structural typing

Forst types are defined by shape. Inheritance trees are not used. Function parameters and return values use record syntax:
Anonymous records work at call sites:

Explicit where it matters

Forst embraces inference in clear cases (return types, obvious locals) but requires explicit annotations where ambiguity would hurt reliability:
  • Function parameters always declare types
  • Struct fields always declare types
  • Nil initializations need an explicit type

Control flow you can trace

Forst steers away from exceptions and implicit jumps. Errors are values. Validation uses ensure and is. Success and failure paths stay explicit. See Ensure and narrowing and Errors and Result.

Packages and imports

Forst uses Go style packages and import paths. You can also import Go packages and call qualified functions (fmt.Println, etc.). See Go interop for current limits.

File layout in a typical backend

A mixed Forst and Go service often looks like this:

Caveats

Forst is not a full Go clone. Several areas are experimental or intentionally different.

Shapes and constraints

Types as schemas with validation and less boilerplate.

Ensure and narrowing

Runtime checks tied to the type system.

Providers (DI)

Declare shared services with use and wire them at entry points.