| 📦 Turbo Golo d710c1b k33g 11h ago | 1 | # Tutorial: your first Golo program in Turbo Golo |
| 2 | |
| 3 | 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. |
| 4 | |
| 5 | 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. |
| 6 | |
| 7 | ## Prerequisites |
| 8 | |
| 9 | Check Go: |
| 10 | |
| 11 | ```bash |
| 12 | go version |
| 13 | ``` |
| 14 | |
| 15 | You should see something like: |
| 16 | |
| 17 | ``` |
| 18 | go version go1.26.5 linux/arm64 |
| 19 | ``` |
| 20 | |
| 21 | Check the interpreter: |
| 22 | |
| 23 | ```bash |
| 24 | golo --version |
| 25 | ``` |
| 26 | |
| 27 | ``` |
| 28 | v0.1.1 | dev.20260802.🤓 |
| 29 | ``` |
| 30 | |
| 31 | If that command is not found, install it first — [a download or one script does it](../how-to/install-goloscript.md). |
| 32 | |
| 33 | ## Step 1 — Install the editor |
| 34 | |
| 35 | ```bash |
| 36 | git clone https://rickub.com/turbo-editors/turbo-golo.git |
| 37 | cd turbo-golo |
| 38 | make install |
| 39 | ``` |
| 40 | |
| 41 | The installer builds, installs, and then checks what it installed. The last lines are: |
| 42 | |
| 43 | ``` |
| 44 | ==> Checking the language server |
| 45 | ✓ golo at /usr/local/bin/golo — completion comes from `golo lsp` |
| 46 | |
| 47 | ==> Ready |
| 48 | ``` |
| 49 | |
| 50 | We now have a `turbo-golo` command. |
| 51 | |
| 52 | ## Step 2 — Make a directory |
| 53 | |
| 54 | ```bash |
| 55 | mkdir /tmp/hello |
| 56 | cd /tmp/hello |
| 57 | ``` |
| 58 | |
| 59 | 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. |
| 60 | |
| 61 | ## Step 3 — Open a file that does not exist yet |
| 62 | |
| 63 | ```bash |
| 64 | turbo-golo hello.golo |
| 65 | ``` |
| 66 | |
| 67 | The screen fills. Along the top: |
| 68 | |
| 69 | ``` |
| 70 | File Edit Search Run Code Options Window Snippets Golo Help |
| 71 | ``` |
| 72 | |
| 73 | 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: |
| 74 | |
| 75 | ``` |
| 76 | 1:1 LSP: ready |
| 77 | ``` |
| 78 | |
| 79 | `LSP: ready` means `golo lsp` — the interpreter, in language-server mode — started in this directory. We will use it in Step 8. |
| 80 | |
| 81 | ## Step 4 — Write the program |
| 82 | |
| 83 | Type this in. Type it exactly; we will look at the colours next. |
| 84 | |
| 85 | ```golo |
| 86 | module hello.World |
| 87 | |
| 88 | # Greet someone several times |
| 89 | struct Greeting = { name, times } |
| 90 | |
| 91 | function greet = |g| { |
| 92 | foreach i in range(1, g: times() + 1) { |
| 93 | println("Hello, " + g: name() + "! (" + i + ")") |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | function main = |args| { |
| 98 | greet(Greeting("Golo", 3)) |
| 99 | } |
| 100 | ``` |
| 101 | |
| 102 | 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. |
| 103 | |
| 104 | Press `F2` to save. The status bar says `Saved hello.golo`. |
| 105 | |
| 106 | ## Step 5 — Read the colours |
| 107 | |
| 108 | Look at what you have typed. In the default `turbo-classic` theme: |
| 109 | |
| 110 | | What | Colour | |
| 111 | | --- | --- | |
| 112 | | `module`, `struct`, `function`, `foreach`, `in` | bright white, bold — keywords | |
| 113 | | `hello.World`, `Greeting` | bright cyan — a module path, and a type | |
| 114 | | `greet`, where it is declared and where it is called | bright yellow, bold — functions | |
| 115 | | `range`, `println` | bright cyan, bold — functions the interpreter provides | |
| 116 | | `name`, `times`, `g`, `i`, `args` | bright yellow — ordinary names | |
| 117 | | `"Hello, "`, `"! ("`, `")"`, `"Golo"` | green — strings | |
| 118 | | `1`, `3` | magenta — numbers | |
| 119 | | `# Greet someone several times` | grey — a comment | |
| 120 | | `\|`, `:`, `+`, `=` | white — operators | |
| 121 | |
| 122 | Two of those rows are worth a second look. |
| 123 | |
| 124 | **`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. |
| 125 | |
| 126 | **`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). |
| 127 | |
| 128 | ## Step 6 — Give the project its tools |
| 129 | |
| 130 | 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`. |
| 131 | |
| 132 | The menu holds two items, and only one of them is available: |
| 133 | |
| 134 | ``` |
| 135 | ┌───────────────────┐ |
| 136 | │ Create tools file │ |
| 137 | │ Open tools file │ ← greyed out; there is no file to open yet |
| 138 | └───────────────────┘ |
| 139 | ``` |
| 140 | |
| 141 | Choose **Create tools file**. |
| 142 | |
| 143 | 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. |
| 144 | |
| 145 | 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. |
| 146 | |
| 147 | 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. |
| 148 | |
| 149 | ## Step 7 — Run it |
| 150 | |
| 151 | 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: |
| 152 | |
| 153 | ``` |
| 154 | ┌──────────────── Run ────────────────┐ |
| 155 | │ script, e.g. main.golo │ |
| 156 | │ [ ] │ |
| 157 | └─────────────────────────────────────┘ |
| 158 | ``` |
| 159 | |
| 160 | Type `hello.golo` and press `Enter`. A terminal window opens and the program runs in it: |
| 161 | |
| 162 | ``` |
| 163 | Hello, Golo! (1) |
| 164 | Hello, Golo! (2) |
| 165 | Hello, Golo! (3) |
| 166 | ``` |
| 167 | |
| 168 | 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. |
| 169 | |
| 170 | ## Step 8 — Break it, and see where |
| 171 | |
| 172 | Go to the end of the file, after the last `}`, and add a comment the way another language would write it: |
| 173 | |
| 174 | ```golo |
| 175 | // run it |
| 176 | ``` |
| 177 | |
| 178 | Press `F2` to save. |
| 179 | |
| 180 | Within a second, two things happen. A red `×` appears in the gutter, just left of that line's number. And the status bar reads: |
| 181 | |
| 182 | ``` |
| 183 | ⚠ GoloScript has no '//' line comments. GoloScript comments are '#' for a single line (e.g. … |
| 184 | ``` |
| 185 | |
| 186 | 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. |
| 187 | |
| 188 | Change the `//` to `#` and save again; both the mark and the message go away. |
| 189 | |
| 190 | ## Step 9 — Change the theme |
| 191 | |
| 192 | `F10`, then `→` **five times** to reach **Options** — past Edit, Search, Run and Code. Choose **Theme…**. |
| 193 | |
| 194 | A list opens on the theme you are in. Press `↓` to `cobalt` and `Enter`. The whole screen changes, keeping the same shape. |
| 195 | |
| 196 | Press `Alt-X` to leave. The editor asks about unsaved files first, if there are any. |
| 197 | |
| 198 | ## What now? |
| 199 | |
| 200 | You have written a Golo program in the editor, run it, broken it, and seen the editor say where. To go further: |
| 201 | |
| 202 | - To do specific things → the [how-to guides](../how-to/) |
| 203 | - To see exactly what is coloured and how → [languages coloured](../reference/languages.md) |
| 204 | - To understand why the editor is built this way → the [explanation](../explanation/) |