# missing function init in package main

- **ID:** `go/missing-init-function`
- **Domain:** go
- **Category:** compile_error
- **Verification:** ai_generated
- **Fix Rate:** 95%

## Root Cause

Go requires a main() function in the main package for executable programs, but the compiler specifically checks for init() functions only when they are referenced; this error occurs when a package expects an init() function that is not defined.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Go 1.18 | active | — | — |
| Go 1.19 | active | — | — |
| Go 1.20 | active | — | — |

## Workarounds

1. **Ensure the main package has a main() function defined with the correct signature: func main()** (98% success)
   ```
   Ensure the main package has a main() function defined with the correct signature: func main()
   ```
2. **If the package is a library (non-main), change the package declaration to something other than main** (90% success)
   ```
   If the package is a library (non-main), change the package declaration to something other than main
   ```

## Dead Ends

- **** — This only works if the package actually requires init() for initialization; often the real issue is a missing main() function or import cycle. (60% fail)
- **** — Test files are not compiled in normal builds; this hides the real problem. (95% fail)
