A superset of Go with modern language features.
Keep Go packages, generated Go code, and the familiar toolchain.
Notice: GPP is an independent open source project and is not affiliated with or endorsed by Google or the Go project.
GPP is a playful nod to Go++ echoing how C++ grew from C. GPP is distributed under the BSD 3-Clause License, the same license as Go. Bundled third-party components may have separate licenses; see their notices.
GPP adds expressive language features while keeping Go packages, generated code, and the familiar build toolchain in reach. The guides below explain each feature with comparisons and examples.
- Classes — Group fields and methods around an
implicit
this, with concise construction and generated Go structs. - Static methods and factories — Put type-level operations on a class and provide named ways to construct values.
- Polymorphism — Use class values through compatible base types and interfaces, including when calling methods.
- Multiple inheritance — Compose behavior from multiple base classes, with qualified access when members conflict.
- Overloading — Reuse a function or method name for different arities and statically distinguishable argument types.
- Named arguments and defaults — Make call sites clearer and omit arguments that have a declared default.
- Anonymous structs — Pass composite values without declaring one-off structs for every function boundary.
- Enums — Define closed, named value sets with grouped declarations, validation, ordered values, and member metadata.
- Generic classes and functions — Reuse type-safe classes and functions across value types, with Go-compatible type constraints and explicit constructor type arguments.
- Lambdas and the prelude — Write concise functions and use familiar collection, string, and map helpers.
- Extension methods — Add compile-time methods to existing types, including several types in one extension block.
- String interpolation — Embed values in
double-quoted strings, with formatting and
String()support. Raw strings retain their literal Go behavior. - Regular expressions — Compile and use regular expressions through concise prelude helpers.
- Safe access — Use
?.to access members of nullable class values without repeating explicit nil checks. - Lazy error fallback — Use
??to evaluate a fallback only when the value on its left is absent or erroneous. - Exception handling — Keep Go-style error
values while adding
throw,try, typedcatch, andfinallysyntax. - Program exit hook — Register
atExitwork that runs during normal program shutdown. - Annotations and introspection — Declare typed metadata, validate its targets, and inspect it at runtime.
- Serialization — Generate JSON, YAML, and GOB conversion methods from class annotations and field metadata.
- HTTP servers and routes — Build servers with annotated routing, request binding, middleware, and lifecycle hooks.
- OpenAPI, Swagger, and OAuth — Generate API documentation and interactive Swagger UI, with OAuth/OIDC support.
- Typed SQL queries — Return scalars, anonymous or named structs, or models from full SQL statements.
- ORM models — Map annotated models to tables and use model-oriented queries and persistence hooks.
- Typed templates — Define HTML/XML templates
as functions and render them with Go's
html/templateprotections. - External template reloads — Reload
.gpp.tplfiles during development without rebuilding the server. - Embedded assets — Include files and directories in the program through source-level declarations.
- Cron scheduling — Schedule annotated functions or dynamic jobs with explicit start and stop controls.
- Experimental packages — Explore experimental packages, including the HTTP client and durable work queue.
- Suite-based tests — Organize tests into
suites, methods, and annotations, then run them through
gpp test.
- Go compatibility — Use ordinary Go imports
and dotted GPP packages mapped to module paths; standalone programs can omit
package main. - Mixed Go and GPP builds — Call Go from GPP and GPP from Go while compiling both languages in one project.
- Project CLI — Initialize, build, run,
test, format, and inspect GPP projects with the
gppcommand. - Formatter — Format GPP syntax consistently and check formatting in CI.
- Source documentation — Read declarations and API documentation directly from GPP source.
- Language server — Get editor diagnostics, completion, navigation, semantic highlighting, and quick fixes.
The GPP VS Code extension provides GPP syntax highlighting, snippets, formatting, and optional language-server support for diagnostics, completion, and navigation.
The editor view below shows the Todo model in the full example.
GPP requires Go 1.27 or newer. This enables generic methods declared directly on classes in generated projects, alongside generic free functions, static methods, and extension methods.
The formula currently tracks |
|
For Go developers who already have Go 1.27 or newer and want to try GPP quickly: |
It provides one gpp executable with project commands:
gpp init|compile|build|run|clean|fmt|fiximports|test|doc|env|doctor|version|lsp
Create and run a starter project:
gpp init hello
cd hello
gpp rungpp init creates a root go.mod and initializes a Git repository with an
init commit when the target is not already inside a Git worktree. Dependency
resolution happens when you build or run the project. The initial commit
includes only the generated project files.
Build a native executable. Intermediate Go source remains in the hidden compiler workspace rather than beside the GPP source:
gpp build examples/hello.gpp -o ./helloCompiler warnings are hidden by default. Pass -warnings to show them:
gpp build -warnings examples/hello.gppgpp build reuses generated Go and the executable while its inputs remain
unchanged. After a GPP source edit, the compiler reuses generated output for
unaffected packages, and Go's build cache reuses unaffected Go packages. Native
Go helper or embedded file changes are tracked as build inputs. gpp clean
clears the generated workspace and its cache state.
Use gpp doctor to check the Go toolchain and embedded standard library, and
gpp clean to remove generated build artifacts.
Format GPP source with the shared canonical formatter. It uses four-space indentation, preserves comments and opaque literal/template content, and supports CI-friendly check mode:
gpp fmt examples/hello.gpp
gpp fmt --check ./...
gpp fmt --stdout examples/hello.gppUse gpp fiximports to add missing imports, remove unused named imports, and
resolve package-name clashes when a unique available package matches qualified
names in GPP source. It prefers bundled GPP packages and uses std-prefixed
aliases for colliding standard-library imports. It supports --check and
--stdout modes.
Pass -emit-go to gpp build when you want the generated Go workspace path
reported for inspection.
GPP tests use the bundled gpp/test suite library and ordinary Go test
execution underneath:
gpp test examples/testing.gpp
gpp test --tag crud examples/testing.gpp
gpp test --priority high examples/testing.gppThe compiler's CI also runs go test ./... and
scripts/smoke-examples.sh. That smoke test creates
a fresh project with gpp init, copies in the complete examples tree, then
runs or builds every example (and executes the GPP testing example). Run it
locally before submitting compiler changes:
./scripts/smoke-examples.shInspect GPP source-level documentation without exposing generated Go:
gpp doc gpp/http.Server
gpp doc string.TrimSpace
gpp doc --json gpp/http.Server
gpp doc --search templateStart the editor language server over standard input/output:
gpp lspThe server keeps open-document overlays in memory and provides diagnostics,
completion, hover, navigation, references, rename, symbols, formatting, and
signature help without running a Go backend build on every change. Use
gpp lsp --log=/tmp/gpp-lsp.log when protocol-side diagnostics are needed;
logs never go to stdout.
The technical documentation is built with VitePress. It includes a practical
landing page, getting-started and language guides, compiler/tooling notes, and
the specifications mirrored from spec/ at build time:
npm install
npm run docs:devBuild and preview the static site locally:
npm run docs:build
npm run docs:previewPushes to main build and deploy the site through GitHub Pages using the
workflow in .github/workflows/docs.yml. In the repository settings, set
Pages → Build and deployment → Source to GitHub Actions once.
For a complete project build, use the build subcommand. It clears stale
generated source, runs go mod tidy to resolve imports, and runs go build:
gpp build examples/hello.gppUse run for the same generation and dependency setup followed by execution:
gpp run examples/hello.gppgpp run also accepts .go files and Go-only directories. Those files go
through the GPP compiler before the generated Go is built and run:
gpp run ./main.go -- program-argument
gpp run ./cmd/serverDuring gpp run, external .gpp.tpl sources are watched when used with
gpp/http.Server; valid edits reload automatically and invalid edits leave
the previous templates active. Production gpp build uses the compiled
template sources without starting a watcher.
Use a separate output directory when switching between standalone examples:
gpp run -output /tmp/gpp-orm examples/orm.gppMultiple GPP files can be passed to the same build. For example, the cross-package example is built and run as one generated project:
gpp run \
examples/packages/people.gpp \
examples/packages/main.gppGPP and Go can also live in the same build. The mixed-compilation examples demonstrate both directions:
gpp run -output /tmp/gpp-go-from-gpp examples/mixed/go_from_gpp
gpp run -output /tmp/gpp-go-imports-gpp examples/mixed/go_imports_gppThe first lets GPP call functions from native.go; the second lets ordinary
Go import the generated generated/mixed package.
The ORM example also resolves its SQLite dependency automatically:
gpp run -output /tmp/gpp-orm examples/orm.gppBuild an executable at a chosen path with -o:
gpp build -o ./hello examples/hello.gppGenerated Go is written to a stable, per-project workspace under the system
cache. The CLI creates that workspace's go.mod with the default module path
generated; choose another path with -module when local Go package imports
need a real module path. Set GPP_CACHE to choose the cache root:
GPP_CACHE=/var/cache/gpp gpp -module example.com/myapp examples/*.gppChoose a different generated output directory with -output:
gpp -output build/gpp examples/hello.gppThe standard GPP prelude is available automatically. Disable it for minimal
or diagnostic builds with -no-prelude.
The enum example demonstrates implicit and explicit values, grouped enum declarations, validated conversion, and metadata:
gpp run examples/enums.gppExpression-level error fallback is demonstrated by:
gpp run examples/expr_catch.gppClass introspection exposes generated name, fields, methods,
annotations, owner, type, get, set, and addr metadata while
preserving ordinary Go structs and stdlib interoperability.
GPP is released under the BSD 3-Clause License.
Copyright (c) 2026 Telga Technologies Pvt Ltd and GPP contributors.
See LICENSE for details.
When redistributing source code from this GPP compiler project, retain the copyright notice, all three license conditions, and the warranty disclaimer from LICENSE.