You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/content/docs/languages/go.md
+46-1Lines changed: 46 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,10 +11,19 @@ description: Using krait with Go projects.
11
11
go install golang.org/x/tools/gopls@latest
12
12
```
13
13
14
+
On macOS without Go installed, krait can install gopls via Homebrew:
15
+
16
+
```bash
17
+
krait server install go # uses brew if go is not in PATH
18
+
```
19
+
20
+
Note: installing the gopls binary alone is not sufficient — the Go toolchain must also be in PATH at runtime (see [Troubleshooting](#troubleshooting) below).
21
+
14
22
## Requirements
15
23
16
24
-`go.mod` at project root
17
-
- Go toolchain in PATH
25
+
- Go toolchain in PATH (`go` command available)
26
+
- gopls binary installed
18
27
19
28
## Zero Config
20
29
@@ -46,3 +55,39 @@ krait find symbol Server.Handle
46
55
## Performance
47
56
48
57
gopls is fast even on large projects. `find symbol` and `hover` typically respond in 30-60ms on warm daemon.
58
+
59
+
## Troubleshooting
60
+
61
+
### `warn go: gopls is installed but requires go in PATH`
62
+
63
+
gopls is a standalone binary, but it calls the `go` command internally to load module graphs and type-check packages. Installing the gopls binary alone (e.g. via `brew install gopls`) is not enough.
64
+
65
+
**Fix:** Install the Go toolchain from [https://go.dev/dl/](https://go.dev/dl/), then re-index:
66
+
67
+
```bash
68
+
go version # verify Go is available
69
+
krait daemon stop
70
+
krait init --force
71
+
```
72
+
73
+
### `indexed 0 files, 0 symbols` with no warning
74
+
75
+
gopls is likely not installed.
76
+
77
+
```bash
78
+
krait server list # check gopls status
79
+
krait server install go # install gopls (requires go in PATH)
gopls is still loading the workspace, or failed to start silently. Restart the daemon:
85
+
86
+
```bash
87
+
krait daemon stop
88
+
krait status # daemon auto-restarts on next command
89
+
```
90
+
91
+
### First `krait init` is slow
92
+
93
+
gopls downloads and caches module dependencies on first use. This is a one-time cost. Large modules (e.g. with many external dependencies) can take 30–60 seconds the first time.
**With a warning line:** the warning tells you exactly what's wrong. Common causes:
11
+
12
+
| Warning | Cause | Fix |
13
+
|---------|-------|-----|
14
+
|`gopls is installed but requires go in PATH`| Go toolchain missing | Install Go from [go.dev/dl](https://go.dev/dl/)|
15
+
|`failed to install gopls: Go is required`| gopls not installed, no Go in PATH | Install Go, then `krait server install go`|
16
+
|`no LSP server configured for <lang>`| Language not supported | Check [Language Support](/languages/)|
17
+
18
+
**With no warning:** the LSP server may not be installed.
19
+
20
+
```bash
21
+
krait server list # see what's installed
22
+
krait server install <lang>
23
+
krait init --force
24
+
```
25
+
26
+
### `krait init` re-indexes everything every time
27
+
28
+
The index is content-addressed (BLAKE3 hashes). Files only re-index when their content changes. If everything re-indexes on each run, the `.krait/index.db` may have been deleted or is being regenerated.
29
+
30
+
Check that `.krait/` is not in your `.gitignore` or being cleaned by another tool.
31
+
32
+
### Symbols are stale after editing a file
33
+
34
+
The file watcher marks edited files dirty within ~500ms. If symbols appear stale:
35
+
36
+
```bash
37
+
krait status # check "dirty files" count
38
+
krait init --force # full re-index if watcher has fallen behind
39
+
```
40
+
41
+
---
42
+
43
+
## Daemon Issues
44
+
45
+
### `krait status` hangs or returns no output
46
+
47
+
The daemon may have crashed. Remove the stale socket and restart:
48
+
49
+
```bash
50
+
krait daemon stop # cleans up PID + socket files
51
+
krait status # daemon auto-restarts
52
+
```
53
+
54
+
### `krait daemon start` fails with "already running"
55
+
56
+
A stale PID file exists from a previous crash. Stop the daemon to clean it up:
57
+
58
+
```bash
59
+
krait daemon stop
60
+
krait daemon start
61
+
```
62
+
63
+
### Daemon shuts down unexpectedly
64
+
65
+
The daemon idles out after 30 minutes of inactivity by default. It auto-restarts on the next command — no manual action needed.
66
+
67
+
To keep it alive longer, set `KRAIT_IDLE_TIMEOUT` (in seconds) before starting:
### `krait server list` shows a server as `not installed`
87
+
88
+
Run the install command shown in the output:
89
+
90
+
```bash
91
+
krait server install rust # installs rust-analyzer
92
+
krait server install go # installs gopls
93
+
```
94
+
95
+
### A language server keeps crashing
96
+
97
+
```bash
98
+
krait server status # see running LSP processes
99
+
krait daemon stop # full restart
100
+
krait status # re-boot all servers
101
+
```
102
+
103
+
If crashes persist, the language server binary may be corrupted. Remove managed servers and reinstall:
104
+
105
+
```bash
106
+
krait server clean # removes ~/.krait/servers/
107
+
krait server install <lang>
108
+
```
109
+
110
+
---
111
+
112
+
## macOS-Specific Issues
113
+
114
+
### `krait` binary crashes immediately (exit 137)
115
+
116
+
After installing or updating the krait binary, macOS may cache the old binary's security state. Overwriting a binary in-place with `cp` can trigger this.
117
+
118
+
**Fix:** Remove the old binary before copying:
119
+
120
+
```bash
121
+
rm /usr/local/bin/krait
122
+
cp ./target/release/krait /usr/local/bin/krait
123
+
```
124
+
125
+
### `spctl --assess` reports `rejected`
126
+
127
+
`spctl` checks against the App Store or Developer ID policy. Locally built binaries are always rejected by this check, but they still run fine. This is not an error.
128
+
129
+
---
130
+
131
+
## Command Errors
132
+
133
+
### `error: LSP servers still indexing`
134
+
135
+
The daemon just started and language servers are still loading. Wait a few seconds:
136
+
137
+
```bash
138
+
krait status # check "pending" count
139
+
```
140
+
141
+
Retry the command once `krait status` shows no pending servers.
142
+
143
+
### `no results` from `krait find symbol`
144
+
145
+
- The symbol name may be misspelled or use wrong casing (symbol lookup is exact)
146
+
- The file may not be indexed yet — run `krait init`
147
+
- The language server may still be loading — check `krait status`
148
+
149
+
Try a text search as a fallback:
150
+
151
+
```bash
152
+
krait search MySymbol src/
153
+
```
154
+
155
+
### `krait check` returns no diagnostics on a file with errors
156
+
157
+
The language server may not have finished loading the file. Wait for `krait status` to show no pending servers, then retry. If the issue persists, the file may be outside the indexed workspace — verify with `krait status`.
158
+
159
+
---
160
+
161
+
## Getting More Information
162
+
163
+
Run any command with `RUST_LOG=krait=debug` to see detailed logs from the CLI:
164
+
165
+
```bash
166
+
RUST_LOG=krait=debug krait find symbol MyStruct
167
+
```
168
+
169
+
For daemon-level logs, run the daemon in the foreground:
170
+
171
+
```bash
172
+
krait daemon stop
173
+
RUST_LOG=krait=debug krait daemon start # keep terminal open
0 commit comments