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 bodyCommon 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
- Open the line the compiler points to.
- Ensure the opening
{follows the parameter list on the same line. - 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
gofmtso 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
Go "non-declaration statement outside function body" in CIFix Go "syntax error: non-declaration statement outside function body" in CI - executable code was placed at…
Go "syntax error: unexpected newline in argument list" in CIFix Go "syntax error: unexpected newline in argument list; possibly missing comma or )" in CI - a call spans…
Go "X redeclared in this block / other declaration of X" in CIFix Go "X redeclared in this block: other declaration of X" in CI - two declarations with the same name exist…