{"record":{"id":"8cd252602a1fbd8a","repo":"golang/go","slug":"no-matching-files-found","errorCode":null,"errorMessage":"no matching files found","messagePattern":"no matching files found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/load/pkg.go","lineNumber":2305,"sourceCode":"\t\t\t\t\t}\n\t\t\t\t\tcount++\n\t\t\t\t\tif have[rel] != pid {\n\t\t\t\t\t\thave[rel] = pid\n\t\t\t\t\t\tlist = append(list, rel)\n\t\t\t\t\t}\n\t\t\t\t\treturn nil\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, nil, err\n\t\t\t\t}\n\t\t\t\tif count == 0 {\n\t\t\t\t\treturn nil, nil, fmt.Errorf(\"cannot embed directory %s: contains no embeddable files\", rel)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif len(list) == 0 {\n\t\t\treturn nil, nil, fmt.Errorf(\"no matching files found\")\n\t\t}\n\t\tsort.Strings(list)\n\t\tpmap[pattern] = list\n\t}\n\n\tfor file := range have {\n\t\tfiles = append(files, file)\n\t}\n\tsort.Strings(files)\n\treturn files, pmap, nil\n}\n\nfunc validEmbedPattern(pattern string) bool {\n\treturn pattern != \".\" && fs.ValidPath(pattern)\n}\n\n// isBadEmbedName reports whether name is the base name of a file that\n// can't or won't be included in modules and therefore shouldn't be treated","sourceCodeStart":2287,"sourceCodeEnd":2323,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/load/pkg.go#L2287-L2323","documentation":"After processing a single pattern (end of the per-pattern loop body at line 2304), if the accumulated `list` is empty the pattern matched nothing at all — no file, no directory, nothing. This is distinct from 889 (a directory matched but was empty): here the glob itself produced no usable match. It is an error rather than a silent skip so that misspelled embed patterns are caught at build time.","triggerScenarios":"//go:embed of a path that does not exist under the package directory, or that only matches hidden/badly-named files at the top level (no directory descent). E.g. `//go:embed typo.txt`.","commonSituations":"Typo in the pattern; assets not yet checked in; CI building from a shallow checkout that omits the assets; case mismatch in the pattern.","solutions":["Verify the path in the //go:embed directive exists relative to the .go file's package directory.","Check git tracking: `git ls-files <pattern>` — if empty, the files are not in the repo.","Fix typos and case; embed patterns are case-sensitive on all platforms."],"exampleFix":"// before: //go:embed statik\n// after: //go:embed static","handlingStrategy":"validation","validationCode":"// Verify an embed pattern resolves to at least one match before building.\npackage embedcheck\n\nimport (\n\t\"errors\"\n\t\"os\"\n\t\"path/filepath\"\n)\n\nfunc EmbedPatternMatches(pkgDir, pattern string) error {\n\tmatches, err := filepath.Glob(filepath.Join(pkgDir, pattern))\n\tif err != nil {\n\t\treturn errors.New(\"bad embed pattern: \" + err.Error())\n\t}\n\tif len(matches) == 0 {\n\t\treturn errors.New(\"embed pattern matched nothing: \" + pattern)\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always `git ls-files <pattern>` after writing a //go:embed line — if it is empty in git, it will be empty in CI.","Treat embed patterns as case-sensitive on all platforms."],"tags":["embed","go-embed","patterns"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}