{"record":{"id":"874710add3ea8637","repo":"microsoft/typescript-go","slug":"s-w","errorCode":null,"errorMessage":"%s: %w","messagePattern":"%s: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"_tools/cmd/checkmodpaths/main.go","lineNumber":45,"sourceCode":"\tvar errors []error\n\terr = fs.WalkDir(os.DirFS(path), \".\", func(p string, d fs.DirEntry, err error) error {\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif p == \".\" {\n\t\t\treturn nil\n\t\t}\n\n\t\tif p[0] == '.' || p[0] == '_' {\n\t\t\tif d.IsDir() {\n\t\t\t\treturn fs.SkipDir\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\n\t\tif err := module.CheckFilePath(p); err != nil {\n\t\t\terrors = append(errors, fmt.Errorf(\"%s: %w\", p, err))\n\t\t}\n\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\tfmt.Println(\"Error walking the directory:\", err)\n\t\treturn 1\n\t}\n\n\tif len(errors) > 0 {\n\t\tfor _, err := range errors {\n\t\t\tfmt.Println(err)\n\t\t}\n\t\treturn 1\n\t}\n\n\tfmt.Println(\"All module paths are valid.\")\n\treturn 0","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/_tools/cmd/checkmodpaths/main.go#L27-L63","documentation":"checkmodpaths wraps golang.org/x/mod/module.CheckFilePath failures with the offending file's path. CheckFilePath validates that each repository path is a valid, portable Go-module file path (slash-separated, no empty/./.. elements, no Windows-reserved device names, no trailing ~ or leading dots, valid characters).","triggerScenarios":"Running the checkmodpaths tool over a repo tree containing a file whose path violates module path rules: 'aux.c', 'CON', 'foo~', 'a:b.txt', elements starting with '.' or containing backslashes/illegal code points.","commonSituations":"CI checks on repos that must be importable as Go modules; files committed from Windows with reserved names; editor backup files ('file.rs~') accidentally committed.","solutions":["Rename the offending file listed before the colon to a valid module path (no reserved device names, no trailing ~, no ':' etc.)","Remove accidentally committed backup/temp files","git mv the path if case-only or structural fixes are needed, then re-run checkmodpaths <path>"],"exampleFix":"# before\nrepo/aux.c        # 'aux' is a reserved device name\nrepo/notes.md~    # trailing '~' is invalid\n\n# after\ngit mv repo/aux.c repo/auxiliary.c\nrm repo/notes.md~\ncheckmodpaths repo","handlingStrategy":"validation","validationCode":"import \"golang.org/x/mod/module\";\nif err := module.CheckFilePath(filepath.ToSlash(relPath)); err != nil { /* rename file before committing */ }","typeGuard":"func validModPath(p string) bool { return module.CheckFilePath(p) == nil }","tryCatchPattern":"if err := module.CheckFilePath(p); err != nil { log.Printf(\"%s: %v — rename or remove this file\", p, err); }","preventionTips":["Run checkmodpaths in CI over the repo root","Never commit editor backups (*~) or Windows reserved device names","Add a pre-commit hook rejecting files failing module.CheckFilePath"],"tags":["go","tooling","filesystem","ci"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}