| 📦 Turbo Go 3d7798b k33g 13h ago | 1 | # Tutorial: your first file in Turbo Go |
| 2 | |
| 3 | By the end of this tutorial, you will have built the editor, written a small Go program inside it, watched the keywords turn colour as you typed, saved the file, and run it. It takes about ten minutes. |
| 4 | |
| 5 | No prior knowledge of Turbo Go is needed. You need Go 1.26 or later and a terminal — that is all. |
| 6 | |
| 7 | ## Prerequisites |
| 8 | |
| 9 | Check that Go is there: |
| 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 | If that command fails, install Go first: https://go.dev/dl/ |
| 22 | |
| 23 | ## Step 1 — Build the editor |
| 24 | |
| 25 | From the project directory, type: |
| 26 | |
| 27 | ```bash |
| 28 | make build |
| 29 | ``` |
| 30 | |
| 31 | You should see: |
| 32 | |
| 33 | ``` |
| 34 | go build -o bin/turbo-go . |
| 35 | ``` |
| 36 | |
| 37 | and then nothing more. Silence is success: Go says nothing when a build works. |
| 38 | |
| 39 | We now have an executable at `bin/turbo-go`. Remember where it is, so we can start it from anywhere: |
| 40 | |
| 41 | ```bash |
| 42 | export TURBO="$PWD/bin/turbo-go" |
| 43 | ``` |
| 44 | |
| 45 | ## Step 2 — Create a place to work |
| 46 | |
| 47 | Turbo Go is at its best inside a Go module, so let us make one: |
| 48 | |
| 49 | ```bash |
| 50 | mkdir -p /tmp/hello && cd /tmp/hello |
| 51 | go mod init hello |
| 52 | ``` |
| 53 | |
| 54 | You should see: |
| 55 | |
| 56 | ``` |
| 57 | go: creating new go.mod: module hello |
| 58 | ``` |
| 59 | |
| 60 | We have just created an empty Go module. |
| 61 | |
| 62 | ## Step 3 — Open the editor |
| 63 | |
| 64 | Start Turbo Go on a file that does not exist yet: |
| 65 | |
| 66 | ```bash |
| 67 | $TURBO main.go |
| 68 | ``` |
| 69 | |
| 70 | The screen fills with a blue desktop. You should see: |
| 71 | |
| 72 | - a **menu bar** across the top: `File Edit Search Run Code Options Window Snippets Go Help` |
| 73 | - a **window** framed in a double line, titled `main.go` |
| 74 | - a **status bar** along the bottom: `F1 Describe F2 Save F3 Open …` |
| 75 | |
| 76 | The cursor is blinking at line 1, column 1 — the status bar says `1:1` on the right. |
| 77 | |
| 78 | We are inside the editor. |
| 79 | |
| 80 | ## Step 4 — Type a Go program |
| 81 | |
| 82 | Type these five lines, pressing Enter at the end of each: |
| 83 | |
| 84 | ```go |
| 85 | package main |
| 86 | |
| 87 | import "fmt" |
| 88 | |
| 89 | func main() { |
| 90 | ``` |
| 91 | |
| 92 | Watch the colours as you type. `package`, `import` and `func` turn **white and bold** the moment the word ends: they are keywords. `"fmt"` turns **green**: it is a string. `main` turns **yellow and bold** as soon as you type the `(` after it, because that makes it a function. |
| 93 | |
| 94 | Now press **Tab**. The cursor jumps to column 9 — the status bar on the right changes to `5:2`, because a tab is one character wide in the file even though it fills eight columns on screen. |
| 95 | |
| 96 | Type the body of the function: |
| 97 | |
| 98 | ```go |
| 99 | fmt.Println("Hello from Turbo Go!") |
| 100 | ``` |
| 101 | |
| 102 | > When you type the `.` after `fmt`, the status bar briefly shows a message about the language server. That is expected: completion needs `gopls`, which we have not set up. The [completion guide](../how-to/enable-completion.md) covers it later; ignore it for now. |
| 103 | |
| 104 | Press **Enter**. Look at the new line: the cursor is *already* at column 9. Turbo Go copied the indentation of the line above, which is what you want nine times out of ten. |
| 105 | |
| 106 | This time we do not want it, so press **Shift-Tab** to take that indent back off, then type the closing brace: |
| 107 | |
| 108 | ```go |
| 109 | } |
| 110 | ``` |
| 111 | |
| 112 | The window title now reads `main.go *`. The star means there are unsaved changes. |
| 113 | |
| 114 | We have just written a complete Go program, with the editor colouring it as we went. |
| 115 | |
| 116 | ## Step 5 — Save it |
| 117 | |
| 118 | Press **F2**. |
| 119 | |
| 120 | The star disappears from the title, and the status bar says: |
| 121 | |
| 122 | ``` |
| 123 | Saved main.go |
| 124 | ``` |
| 125 | |
| 126 | We have just written the file to disk. |
| 127 | |
| 128 | ## Step 6 — Look at the file from outside |
| 129 | |
| 130 | Leave the editor by pressing **Alt-X**. The terminal comes back as it was. |
| 131 | |
| 132 | Check what we wrote: |
| 133 | |
| 134 | ```bash |
| 135 | cat main.go |
| 136 | ``` |
| 137 | |
| 138 | You should see: |
| 139 | |
| 140 | ```go |
| 141 | package main |
| 142 | |
| 143 | import "fmt" |
| 144 | |
| 145 | func main() { |
| 146 | fmt.Println("Hello from Turbo Go!") |
| 147 | } |
| 148 | ``` |
| 149 | |
| 150 | ## Step 7 — Run it |
| 151 | |
| 152 | ```bash |
| 153 | go run main.go |
| 154 | ``` |
| 155 | |
| 156 | You should see: |
| 157 | |
| 158 | ``` |
| 159 | Hello from Turbo Go! |
| 160 | ``` |
| 161 | |
| 162 | That is a working Go program, written entirely inside the editor. |
| 163 | |
| 164 | ## Step 8 — Change the theme |
| 165 | |
| 166 | Open the file again: |
| 167 | |
| 168 | ```bash |
| 169 | $TURBO main.go |
| 170 | ``` |
| 171 | |
| 172 | Press **F10**. The `File` menu drops open. Press **→** five times: the menu walks along the bar to `Options`, whose first item, `Theme…`, is highlighted. Press **Enter**. |
| 173 | |
| 174 | A list of eleven appears, in alphabetical order, with the theme you are using already highlighted: |
| 175 | |
| 176 | ``` |
| 177 | borland-light |
| 178 | cappuccino |
| 179 | catppuccin-frappe |
| 180 | catppuccin-latte |
| 181 | cobalt |
| 182 | darcula |
| 183 | intellij-light |
| 184 | monochrome-dark |
| 185 | monochrome-light |
| 186 | turbo-classic |
| 187 | turbo-dark |
| 188 | ``` |
| 189 | |
| 190 | `turbo-classic` is the highlighted row, because that is the theme you are in. Press **↓** once to move to `turbo-dark`, then press **Enter**. |
| 191 | |
| 192 | The whole editor repaints in dark grey, and the status bar says `Theme: Turbo Dark`. |
| 193 | |
| 194 | Press **Alt-X** to leave. |
| 195 | |
| 196 | ## What now? |
| 197 | |
| 198 | You have built the editor, written a Go program in it, saved it, run it, and changed how it looks. |
| 199 | |
| 200 | - To do specific things — enable completion, write a theme of your own, search a file → see the [how-to guides](../how-to/) |
| 201 | - To look up a key or a menu item → see the [reference](../reference/) |
| 202 | - To understand how the colouring and the completion actually work → see the [explanation](../explanation/) |