{"record":{"id":"6a3a311cd25f735c","repo":"golang/go","slug":"import-path-contains-space-character-q","errorCode":null,"errorMessage":"import path contains space character: %q","messagePattern":"import path contains space character: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/compile/internal/noder/import.go","lineNumber":326,"sourceCode":"\t\treturn errors.New(\"import path contains NUL\")\n\t}\n\n\tfor ri := range base.ReservedImports {\n\t\tif path == ri {\n\t\t\treturn fmt.Errorf(\"import path %q is reserved and cannot be used\", path)\n\t\t}\n\t}\n\n\tfor _, r := range path {\n\t\tswitch {\n\t\tcase r == utf8.RuneError:\n\t\t\treturn fmt.Errorf(\"import path contains invalid UTF-8 sequence: %q\", path)\n\t\tcase r < 0x20 || r == 0x7f:\n\t\t\treturn fmt.Errorf(\"import path contains control character: %q\", path)\n\t\tcase r == '\\\\':\n\t\t\treturn fmt.Errorf(\"import path contains backslash; use slash: %q\", path)\n\t\tcase !allowSpace && unicode.IsSpace(r):\n\t\t\treturn fmt.Errorf(\"import path contains space character: %q\", path)\n\t\tcase strings.ContainsRune(\"!\\\"#$%&'()*,:;<=>?[]^`{|}\", r):\n\t\t\treturn fmt.Errorf(\"import path contains invalid character '%c': %q\", r, path)\n\t\t}\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":308,"sourceCodeEnd":334,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/compile/internal/noder/import.go#L308-L334","documentation":"Returned by checkImportPath when allowSpace is false and a rune in the path is unicode whitespace (unicode.IsSpace). Most internal callers disable spaces; spaces in import paths break the build because they are ambiguous in go.mod, source files, and shell quoting.","triggerScenarios":"An import path contains a space, tab, or other unicode space (U+00A0, em-space, etc.) and the caller passed allowSpace=false (the default for source-level checks).","commonSituations":"Pasting a path from a formatted document that introduced non-breaking spaces; a directory name with spaces being used as an import path; tabs inside an import literal.","solutions":["Remove all whitespace characters from the import path.","Rename directories/files that contain spaces before referencing them as import paths.","If you genuinely need a path-with-spaces module, restructure to avoid it; Go import paths should be space-free."],"exampleFix":"// before\n import \"example.com/my project\"\n// after\n import \"example.com/myproject\"","handlingStrategy":"validation","validationCode":"for _, r := range path {\n    if unicode.IsSpace(r) {\n        return fmt.Errorf(\"whitespace in import path: %q\", path)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid directory names with spaces.","Sanitize pasted import paths for non-breaking spaces."],"tags":["go-compiler","import-path","whitespace","validation"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}