Installation
Requirements
- Go 1.26.9 or later
- macOS, Linux or Windows
CLI
The main craftgo binary runs codegen and project commands.
go install github.com/craftgodotdev/craftgo/cmd/craftgo@latestVerify:
craftgo --helpThe binary lands in $GOBIN (or $GOPATH/bin). Make sure that directory is on your PATH.
Language server (optional)
The LSP powers editor features: completion, diagnostics, hover, go-to-definition, formatting.
go install github.com/craftgodotdev/craftgo/cmd/craftgo-lsp@latestThe LSP is invoked by editor extensions. You do not run it directly.
VS Code extension
Install the craftgo extension from the Marketplace - three equivalent ways:
- In VS Code: open the Extensions panel (
Cmd/Ctrl+Shift+X), search craftgo, click Install. - From the command line:
code --install-extension craftgo.craftgo - From the web: the Marketplace listing.
.craftgo files immediately get syntax highlighting, completion, hover, and diagnostics. The extension auto-spawns craftgo-lsp, so install that too (above) for the language-server features.
Runtime library
Add craftgo as a dependency in your project:
go get github.com/craftgodotdev/craftgoGenerated code imports from pkg/server, pkg/log and pkg/telemetry, plus pkg/rpc for proto services, pkg/events for events and pkg/wire for a bytes @format(raw) field. pkg/events and pkg/wire are modules of their own, which go get github.com/craftgodotdev/craftgo does not fetch; run go mod tidy after craftgo gen to add every module the generated code imports. You do not import these directly in most cases.
Other editors
The LSP speaks standard LSP. Configure your editor to spawn craftgo-lsp for files with extension .craftgo or .cg.
Neovim with nvim-lspconfig:
local lspconfig = require('lspconfig')
local configs = require('lspconfig.configs')
if not configs.craftgo then
configs.craftgo = {
default_config = {
cmd = { 'craftgo-lsp' },
filetypes = { 'craftgo' },
root_dir = lspconfig.util.root_pattern('go.mod', '.git'),
},
}
end
lspconfig.craftgo.setup({})Updating
go install github.com/craftgodotdev/craftgo/cmd/craftgo@latest
go install github.com/craftgodotdev/craftgo/cmd/craftgo-lsp@latest
go get -u github.com/craftgodotdev/craftgoAfter updating the LSP binary, restart your editor's language server (in VS Code: Cmd+Shift+P -> craftgo: Restart Language Server).