5-Minute Tutorial
This tutorial gets you through a minimal Targo workflow quickly:
- create a project
- use a Go standard library package
- run
check,run, andbuild
Create a project
bash
npx @targo/create-targo hello-server
cd hello-server
targo initReplace src/main.ts
typescript
import { Fprintf, Println } from "fmt";
import { HandleFunc, ListenAndServe, Request, ResponseWriter } from "net/http";
function handler(w: ResponseWriter, r: Request): void {
const name = r.URL.Path.slice(1) || "World";
Fprintf(w, "Hello, %s!", name);
}
export function main(): void {
HandleFunc("/", handler);
Println("Server starting on http://localhost:8080");
ListenAndServe(":8080", null);
}Check and run
bash
targo check
targo runThen open:
http://localhost:8080/http://localhost:8080/Targo
Build
bash
targo buildInspect dist/ if you want to verify the output, but treat it as generated code.