{"record":{"id":"5c90ff73e5edfdbe","repo":"lionsoul2014/ip2region","slug":"config-searchers-must-0","errorCode":null,"errorMessage":"config.searchers must > 0","messagePattern":"config\\.searchers must > 0","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"binding/golang/service/searcher_pool.go","lineNumber":37,"sourceCode":"// @Date   2025/12/03\n\ntype SearcherPool struct {\n\t// config\n\tconfig *Config\n\n\t// searcher pool\n\tpool chan *xdb.Searcher\n\n\t// for pool close\n\tclosing chan struct{}\n\n\t// searcher number that was loaned out\n\tloanCount int32\n}\n\nfunc NewSearcherPool(config *Config) (*SearcherPool, error) {\n\tif config.searchers < 1 {\n\t\treturn nil, fmt.Errorf(\"config.searchers must > 0\")\n\t}\n\n\tvar eExit = false\n\tvar spObj = &SearcherPool{\n\t\tconfig: config,\n\t\tpool:   make(chan *xdb.Searcher, config.searchers+1),\n\n\t\tclosing:   make(chan struct{}, 1),\n\t\tloanCount: 0,\n\t}\n\n\t// error closing\n\tdefer func() {\n\t\tif eExit {\n\t\t\tspObj.Close()\n\t\t}\n\t}()\n","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/lionsoul2014/ip2region/blob/c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1/binding/golang/service/searcher_pool.go#L19-L55","documentation":"Go pool constructor guard: NewSearcherPool refuses a config with searchers < 1 because the channel-based pool needs at least one searcher to be useful; the config was built with an invalid pool size.","triggerScenarios":"Thrown at binding/golang/service/searcher_pool.go:37 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set config.searchers to >= 1 when building the Config","Use the library defaults (20 searchers) via NewIp2RegionWithPath","Validate pool size in your own configuration layer"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1","analyzedAt":"2026-09-02T16:58:39.988Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}