# Tutorial: your first Golo program in Turbo Golo By the end of this tutorial you will have written, run and broken a small Golo program without leaving the editor β€” and seen the editor tell you where the mistake was. No prior knowledge of Turbo Golo is needed. You need Go 1.26 or later to build the editor, and the `golo` interpreter to run the program. ## Prerequisites Check Go: ```bash go version ``` You should see something like: ``` go version go1.26.5 linux/arm64 ``` Check the interpreter: ```bash golo --version ``` ``` v0.1.1 | dev.20260802.πŸ€“ ``` If that command is not found, install it first β€” [a download or one script does it](../how-to/install-goloscript.md). ## Step 1 β€” Install the editor ```bash git clone https://rickub.com/turbo-editors/turbo-golo.git cd turbo-golo make install ``` The installer builds, installs, and then checks what it installed. The last lines are: ``` ==> Checking the language server βœ“ golo at /usr/local/bin/golo β€” completion comes from `golo lsp` ==> Ready ``` We now have a `turbo-golo` command. ## Step 2 β€” Make a directory ```bash mkdir /tmp/hello cd /tmp/hello ``` That is the whole of making a Golo project: Golo has no manifest, a script is a file, and a program is a directory of them. **The directory you start the editor in** is where the Golo menu's commands will run, so start it here. ## Step 3 β€” Open a file that does not exist yet ```bash turbo-golo hello.golo ``` The screen fills. Along the top: ``` File Edit Search Run Code Options Window Snippets Golo Help ``` Ten menus, and the ninth is named after the language. In the middle, an empty window titled `hello.golo`. Along the bottom, at the right-hand end, you should see: ``` 1:1 LSP: ready ``` `LSP: ready` means `golo lsp` β€” the interpreter, in language-server mode β€” started in this directory. We will use it in Step 8. ## Step 4 β€” Write the program Type this in. Type it exactly; we will look at the colours next. ```golo module hello.World # Greet someone several times struct Greeting = { name, times } function greet = |g| { foreach i in range(1, g: times() + 1) { println("Hello, " + g: name() + "! (" + i + ")") } } function main = |args| { greet(Greeting("Golo", 3)) } ``` If a completion list drops down while you type β€” a `.` asks for one by itself, and `hello.` is one β€” keep typing or press `Escape`; `Enter` would accept the first entry. Press `F2` to save. The status bar says `Saved hello.golo`. ## Step 5 β€” Read the colours Look at what you have typed. In the default `turbo-classic` theme: | What | Colour | | --- | --- | | `module`, `struct`, `function`, `foreach`, `in` | bright white, bold β€” keywords | | `hello.World`, `Greeting` | bright cyan β€” a module path, and a type | | `greet`, where it is declared and where it is called | bright yellow, bold β€” functions | | `range`, `println` | bright cyan, bold β€” functions the interpreter provides | | `name`, `times`, `g`, `i`, `args` | bright yellow β€” ordinary names | | `"Hello, "`, `"! ("`, `")"`, `"Golo"` | green β€” strings | | `1`, `3` | magenta β€” numbers | | `# Greet someone several times` | grey β€” a comment | | `\|`, `:`, `+`, `=` | white β€” operators | Two of those rows are worth a second look. **`Greeting` is cyan and `greet` is yellow**, and nothing in the editor was told which of them is a type. Golo's convention decides it: structs, unions and their variants are the names people capitalise, so a capital letter is coloured as a type. **`greet` is yellow where it is declared**, after `function`, although no parenthesis follows it there. The name after `function` is a function by position β€” [and that is a deliberate rule](../explanation/colouring-and-completion.md). ## Step 6 β€” Give the project its tools Press `F10` to open the menu bar, then `β†’` **eight times** to reach **Golo** β€” past Edit, Search, Run, Code, Options, Window and Snippets. Faster: press `Alt-G`. The menu holds two items, and only one of them is available: ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Create tools file β”‚ β”‚ Open tools file β”‚ ← greyed out; there is no file to open yet β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` Choose **Create tools file**. A second window opens on the file that was just written, `.turbo-golo/tools.toml`. Read it if you like β€” it explains every key it uses β€” then press `Ctrl-W` to close it. Look at the menu bar: a **Tools** menu has appeared between Golo and Help. The starter file's last entry names a menu of its own, and that one line is the whole mechanism. Open the Golo menu again. It now holds eight commands, and the two items have swapped: `Create tools file` is greyed out, and `Open tools file` is the one you can choose. ## Step 7 β€” Run it Press `Alt-G` and choose **Run**. A box asks for a value before the command runs, because Golo has no manifest that says which file is the program: ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ Run ────────────────┐ β”‚ script, e.g. main.golo β”‚ β”‚ [ ] β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` Type `hello.golo` and press `Enter`. A terminal window opens and the program runs in it: ``` Hello, Golo! (1) Hello, Golo! (2) Hello, Golo! (3) ``` A terminal rather than a dialog, because a program that reads the keyboard has to be answerable. The program has finished, so the window has stopped behaving like a terminal and every key reaches the editor again: press `Ctrl-W` to close it. ## Step 8 β€” Break it, and see where Go to the end of the file, after the last `}`, and add a comment the way another language would write it: ```golo // run it ``` Press `F2` to save. Within a second, two things happen. A red `Γ—` appears in the gutter, just left of that line's number. And the status bar reads: ``` ⚠ GoloScript has no '//' line comments. GoloScript comments are '#' for a single line (e.g. … ``` Nothing asked for that. `golo lsp` publishes it by itself whenever it re-reads the file β€” a syntax error would have earned the same mark, and this one is a lint the server adds because it is the mistake everybody arriving from another language makes first. Change the `//` to `#` and save again; both the mark and the message go away. ## Step 9 β€” Change the theme `F10`, then `β†’` **five times** to reach **Options** β€” past Edit, Search, Run and Code. Choose **Theme…**. A list opens on the theme you are in. Press `↓` to `cobalt` and `Enter`. The whole screen changes, keeping the same shape. Press `Alt-X` to leave. The editor asks about unsaved files first, if there are any. ## What now? You have written a Golo program in the editor, run it, broken it, and seen the editor say where. To go further: - To do specific things β†’ the [how-to guides](../how-to/) - To see exactly what is coloured and how β†’ [languages coloured](../reference/languages.md) - To understand why the editor is built this way β†’ the [explanation](../explanation/)