{
  "id": "go/missing-init-function",
  "signature": "missing function init in package main",
  "signature_zh": "在main包中缺少init函数",
  "regex": "missing function init in package main",
  "domain": "go",
  "category": "compile_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "Go要求main包中有main()函数用于可执行程序，但编译器仅在引用时检查init()函数；当包期望一个未定义的init()函数时会出现此错误。",
  "versions": [
    {
      "version": "Go 1.18",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Go 1.19",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Go 1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This only works if the package actually requires init() for initialization; often the real issue is a missing main() function or import cycle.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Test files are not compiled in normal builds; this hides the real problem.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure the main package has a main() function defined with the correct signature: func main()",
      "success_rate": 0.98,
      "how": "Ensure the main package has a main() function defined with the correct signature: func main()",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the package is a library (non-main), change the package declaration to something other than main",
      "success_rate": 0.9,
      "how": "If the package is a library (non-main), change the package declaration to something other than main",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Ensure the main package has a main() function defined with the correct signature: func main()",
    "If the package is a library (non-main), change the package declaration to something other than main"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://go.dev/ref/spec#Program_execution",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2024-05-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}