Example gallery
The repository examples are complete source trees rather than presentation-only fragments. Documentation recipes embed separately checked source, and behavior-bearing snippets have committed expected output.
Start and core language
Hello worldOne file, one Go import, and one executable entry point.Parse with ResultBridge a Go error, validate a port, and inspect explicit success/failure values.CollectionsTrace copying and shared views across slices, arrays, pointers, allocation, maps, and collection built-ins.Numeric & bitwise operatorsCombine integer flags, shifts, complement, updates, and explicit width conversions.Comparisons & short-circuitingCompare typed values and observe exactly which boolean operands execute.UTF-8 stringsCompare byte length and indexing with Unicode code-point iteration and byte offsets.GenericsInstantiate a generic value struct and call an explicitly typed generic function.Variadics & spreadAccept individual arguments and expand one final typed slice.Defined domain typesGive strings and maps nominal identity and their own method sets.Relative modulesSplit declarations across files with explicit, non-transitive imports.
Types and control flow
Interface polymorphismImplement an interface with a reference class and dispatch through it.Go interface type switchNarrow imported interfaces to concrete pointer types with case-local bindings.Inheritance & downcastsOverride virtual methods and recover a derived class without losing identity.Typed exceptionsOrder typed catches, bridge Go errors, and guarantee cleanup with finally.Nullable flowSnapshot mutable storage and re-establish non-null proofs after writes.Control-flow boundariesObserve defer evaluation, explicit fallthrough, labeled continue, and checked goto rules.Struct receiversCompare copied value receivers with explicit pointer mutation.
Concurrency
Structured tasksStart work eagerly, consume every task once, and join Result-producing work before error propagation.ChannelsSend, receive, close, and observe the checked state after draining.SelectChoose ready channel operations and handle a non-blocking default path.
Go and applications
Command-line applicationBuild a native executable, validate positional arguments, and test exact process output.JSON valuePass a structural object to the real Go encoding/json package.Filesystem round tripPropagate real file errors, detect a short write, and order portable cleanup.Go standard-library valuesUse an imported struct, pointer methods, explicit results, raw errors, and a callback into Go.Test an HTTP routerExercise kinmokusei/http routes with net/http/httptest and no open port.Bounded HTTP fetchTest a caller-owned transport, copied response state, and an oversize failure without opening a socket.Test an emitted packageGenerate a public Go package and exercise its values and Result boundary with go test.External Go moduleLock an exact version, audit its surface, and keep builds offline.React + Gin/FiberOne frontend with interchangeable Kinmokusei framework backends and an independent Go oracle.Complete JSON APIDirect
net/http and encoding/json package interoperability.Native boundaries
C ABI exportGenerate a header, gateway, canonical manifest, and compatibility fingerprint.Incoming C FFIGenerate a checked private cgo package from an ownership manifest.
The documentation check compiles every embedded valid snippet, runs each example with an output contract, validates diagnostic fragments for intentionally invalid sources, and checks generated Go and C-boundary artifacts.
Running repository examples
From a source checkout, invoke the compiler through Go:
sh
go run ./cmd/keika check examples/hello/main.km
go run ./cmd/keika run examples/hello/main.kmProjects with locked external dependencies include their own manifest, lock, and verification instructions. Normal compilation stays offline/read-only with respect to the module graph.