Skip to content

Use Factory Go Language Support

This chapter opens a trusted Go Project, observes maintained local syntax, diagnostics, and completion, and confirms that Factory Go support remains editable when gopls is unavailable.

Before You Begin

If you enter this chapter directly, first complete Prepare the User Guide Exercises.

Complete Use Language Services and Diagnostics. Confirm that Go and gopls are available in the environment used to start Odra:

command -v go
command -v gopls
gopls version

Odra's interoperability acceptance uses gopls v0.23.0. A different compatible version may work, but it is not the recorded acceptance version.

Create a Go Project

Create one disposable module inside the User Guide work area:

mkdir -p ~/odra-guide/work/projects/go-language-service
printf 'module example.com/odra-guide\n\ngo 1.22\n' \
  > ~/odra-guide/work/projects/go-language-service/go.mod
printf 'package main\n\nimport "fmt"\n\nfunc main() { fmt.Println("Odra") }\n' \
  > ~/odra-guide/work/projects/go-language-service/main.go

Open the directory with Open Dir, promote it to a Project, and grant trust to that exact local Project. External language-service processes do not start for an ordinary Dir or an untrusted Project.

Use the Factory Definition

Do not add a Go definition to init.rkt. Odra ships .go recognition, a pinned local Tree-sitter syntax provider, the gopls serve service profile, nearest go.work or go.mod root discovery, and language-service formatting as one Factory bundle.

Personal language configuration remains available for deliberate overrides or additional languages. It is not required for this chapter.

Inspect the Catalog and Session

Open main.go, then run M-x describe-language-support. Confirm these facts:

Run M-x describe-language-service. Wait until the selected session is active and diagnostics and completion are negotiated. The service command is a direct argument vector; Odra does not pass it through a shell.

Exercise Diagnostics and Completion

Replace the function body with:

func main() {
    fmt.Prin
    _ = missingName
}

The undefined identifier produces a diagnostic. Run M-x list-language-diagnostics to inspect it.

Place point after fmt.Prin and press C-M-i. Select one of the Print completion candidates, then undo the accepted edit. The diagnostic and completion use Odra's existing language-independent adapters.

Restore the valid function before continuing.

Observe Unavailable Recovery

Exit Odra, launch it from an environment that cannot resolve gopls, and open the same trusted Project. M-x describe-language-support reports the selected definition as unavailable while main.go remains editable with local syntax.

Restore the normal launch environment and restart Odra. The same Factory configuration resolves gopls again; no init.rkt change is required.

Previous: Use Language Services and Diagnostics · User Guide · Next: Use the Basic Language Pack