Explicit by default
Instead of mirroring all of Node.js, Golt exposes only the primitives it owns and documents.
Golt bundles your TypeScript entry file with esbuild and executes it in a Go-hosted JavaScript engine. It gives backend scripts a small, explicit runtime API: HTTP, DB, filesystem, fetch, crypto, JWT, env and logging.
golt init my-api
cd my-api
code .
golt run app.tsconst app = Golt.App();
app.use(Golt.logger({ format: "dev" }));
app.get("/", (ctx) => {
ctx.Json({
message: "Hello from Golt!",
runtime: "golt",
});
});
app.serve(3000);const db = Golt.db.connect("sqlite", "./app.db");
await db.exec(
"CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT)"
);
await db.exec("INSERT INTO users(name) VALUES (?)", "Ada");
const users = await db.query("SELECT id, name FROM users");
console.log(users);docker pull aztekode/golt:1.0.2
docker run --rm \
-p 3000:3000 \
-v "$PWD":/workspace \
-w /workspace \
aztekode/golt:1.0.2 \
run app.tsGolt is designed for experiments, internal tools, small APIs and backend scripts where you want TypeScript ergonomics with Go-hosted runtime primitives.
Instead of mirroring all of Node.js, Golt exposes only the primitives it owns and documents.
golt init, golt run and golt watch keep the workflow simple.
HTTP routing, SQL access, filesystem helpers, bcrypt, JWT and fetch are available from the runtime.
The CLI creates the runtime project. The VS Code extension handles editor typings when it detects golt.json.
golt init my-api
cd my-api
golt run app.tsapp.tsYour application entry file. It is bundled and executed by the runtime.
golt.jsonProject metadata and workspace marker for the VS Code extension.
.vscode/extensions.jsonRecommends Aztekode.golt-vscode for editor typings.
Golt is available as a Docker image through aztekode/golt. Use it to run a local project without installing the runtime on the host, or as a base image for deployable Golt applications.
Pull aztekode/golt:latest or pin a specific version like aztekode/golt:1.0.2.
Mount your current folder into /workspace and run golt run app.ts inside the container.
Use the image as a base for your own Golt app Dockerfile and expose your application port.
docker run --rm \
-p 3000:3000 \
-v "$PWD":/workspace \
-w /workspace \
aztekode/golt:1.0.2 \
run app.tsdocker run --rm `
-p 3000:3000 `
-v "${PWD}:/workspace" `
-w /workspace `
aztekode/golt:1.0.2 `
run app.tsFROM aztekode/golt:1.0.2
WORKDIR /app
COPY . .
EXPOSE 3000
CMD ["run", "app.ts"]aztekode/golt:1.0.2 instead of relying only on latest.
Golt.App() creates a per-app HTTP server with routes, middleware, static files and a not-found handler.
Routes use Go-style path params like /users/{id}.
const app = Golt.App();
app.use(Golt.logger({ format: "tiny" }));
app.get("/", (ctx) => {
ctx.Send("Hello from Golt HTTP");
});
app.get("/users/{id}", (ctx) => {
ctx.Json({ id: ctx.Param("id") });
});
app.post("/users", (ctx) => {
const body = ctx.ValidateBody({ name: "string" });
if (!body) return;
ctx.Status(201).Json({ ok: true, name: body.name });
});
app.notFound((ctx) => {
ctx.Status(404).Send("not found");
});
app.serve(3000);
Golt wraps Go database/sql. Use db.exec() for statements that do not return rows,
and db.query() for statements that return data.
| Method | Use it for |
|---|---|
| db.exec() | CREATE, INSERT, UPDATE, DELETE, schema changes and writes. |
| db.query() | SELECT and SQL statements that return rows. |
const db = Golt.db.connect("sqlite", "./app.db");
const result = await db.exec(
"INSERT INTO users(name) VALUES (?)",
"Ada"
);
console.log(result.rowsAffected);
const users = await db.query<{ id: number; name: string }>(
"SELECT id, name FROM users"
);
Golt provides a minimal global fetch() powered by Go net/http. It supports method, headers, body and timeout.
const res = await fetch("https://httpbin.org/json", {
method: "GET",
timeout: 15000,
});
if (!res.ok) {
console.log("Request failed:", res.status);
}
const data = await res.json();
console.log(data);Golt.fs exposes simple helpers for small read/write operations.
Golt.fs.writeFile("./hello.txt", "Hello from Golt\n");
const text = Golt.fs.readFile("./hello.txt");
console.log(text);Golt.crypto provides bcrypt hashing. Golt.jwt signs and verifies HS256 tokens.
const hash = await Golt.crypto.hash("password123");
const ok = await Golt.crypto.compare("password123", hash);
const token = Golt.jwt.sign({ sub: "user_123" }, "secret", 24);
const payload = Golt.jwt.verify(token, "secret");
console.log({ ok, payload });The CLI keeps Golt focused on three actions: initialize, run and watch.
| Command | Description |
|---|---|
| golt init <name> | Create a new project folder with app.ts, golt.json and VS Code recommendations. |
| golt run <file.ts> | Bundle and execute a TypeScript entry file. |
| golt watch <file.ts> | Run and restart on TypeScript or JavaScript file changes. |
| docker run aztekode/golt | Run Golt from the official Docker image without installing the runtime locally. |
This is the current small, explicit API surface exposed by Golt.
| Primitive | Purpose |
|---|---|
| console.log | Print JS values to stdout. |
| Golt.App | Create an HTTP app with routing, middleware and server start. |
| Golt.logger | Create logging middleware for app.use(). |
| Golt.db | Connect to SQL databases and run query() / exec(). |
| Golt.fs | Read and write local files. |
| Golt.crypto | Hash and compare passwords with bcrypt. |
| Golt.jwt | Sign and verify JWT tokens. |
| Golt.env | Access host environment variables. |
| fetch | Make outbound HTTP requests. |