Skip to content
Latchkey

Go "missing function body" in CI

The parser saw a function declaration that ends without a { ... } body. In ordinary Go a function must have a body unless it is implemented in assembly.

What this error means

Compilation fails with "missing function body" at a function declaration, often right after a refactor that left a brace or semicolon misplaced.

go build
./util.go:8:1: missing function body

Common causes

A stray semicolon or newline ended the declaration

A semicolon (often inserted automatically) or a misplaced brace terminated the function header before its body.

A forward declaration without an assembly implementation

Declaring func f() with no body is only legal when a matching .s assembly file provides the implementation.

How to fix it

Give the function a body

  1. Open the line the compiler points to.
  2. Ensure the opening { follows the parameter list on the same line.
  3. Add the body, or remove the trailing semicolon that closed the header early.
util.go
func ping() error {
	return nil
}

Provide an assembly stub if intended

If the function is implemented in assembly, add the matching .s file so the bodyless declaration is valid.

How to prevent it

  • Run gofmt so brace placement follows Go style and obvious slips show up.
  • Compile after refactors that move braces between functions.
  • Avoid putting the opening brace on the next line; Go style keeps it on the header line.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →