{"record":{"id":"e97e08b19ba6094a","repo":"golang/go","slug":"q-not-allowed-in-import-path","errorCode":null,"errorMessage":"%q not allowed in import path","messagePattern":"%q not allowed in import path","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/vcs/vcs.go","lineNumber":834,"sourceCode":"\t\t// TODO(rsc): This should not be necessary, but it's required to keep\n\t\t// tests like ../../testdata/script/mod_get_extra.txt from using the network.\n\t\t// That script has everything it needs in the replacement set, but it is still\n\t\t// doing network calls.\n\t\treturn nil, fmt.Errorf(\"no modules on example.net\")\n\t}\n\tif importPath == \"rsc.io\" {\n\t\t// This special case allows tests like ../../testdata/script/govcs.txt\n\t\t// to avoid making any network calls. The module lookup for a path\n\t\t// like rsc.io/nonexist.svn/foo needs to not make a network call for\n\t\t// a lookup on rsc.io.\n\t\treturn nil, fmt.Errorf(\"rsc.io is not a module\")\n\t}\n\t// A common error is to use https://packagepath because that's what\n\t// hg and git require. Diagnose this helpfully.\n\tif prefix := httpPrefix(importPath); prefix != \"\" {\n\t\t// The importPath has been cleaned, so has only one slash. The pattern\n\t\t// ignores the slashes; the error message puts them back on the RHS at least.\n\t\treturn nil, fmt.Errorf(\"%q not allowed in import path\", prefix+\"//\")\n\t}\n\tfor _, srv := range vcsPaths {\n\t\tif !str.HasPathPrefix(importPath, srv.pathPrefix) {\n\t\t\tcontinue\n\t\t}\n\t\tm := srv.regexp.FindStringSubmatch(importPath)\n\t\tif m == nil {\n\t\t\tif srv.pathPrefix != \"\" {\n\t\t\t\treturn nil, importErrorf(importPath, \"invalid %s import path %q\", srv.pathPrefix, importPath)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\t// Build map of named subexpression matches for expand.\n\t\tmatch := map[string]string{\n\t\t\t\"prefix\": srv.pathPrefix + \"/\",\n\t\t\t\"import\": importPath,\n\t\t}","sourceCodeStart":816,"sourceCodeEnd":852,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/vcs/vcs.go#L816-L852","documentation":"A common mistake is passing a URL (e.g., `https://github.com/pkg/errors`) to `go get` instead of an import path (`github.com/pkg/errors`). The go tool detects http: or https: prefixes on the import path and rejects them with a message naming the offending prefix.","triggerScenarios":"Running `go get https://github.com/user/repo` or `go get http://example.com/pkg` — the import path starts with 'http:' or 'https:'.","commonSituations":"Copy-pasting a repository URL from a browser address bar into `go get`; confusion between VCS clone URLs and Go import paths.","solutions":["Remove the http:// or https:// scheme prefix from the path","Use the bare import path: `go get github.com/user/repo` instead of `go get https://github.com/user/repo`","If you need a specific URL, use a replace directive in go.mod"],"exampleFix":"# before\ngo get https://github.com/pkg/errors\n\n# after\ngo get github.com/pkg/errors","handlingStrategy":"validation","validationCode":"# Strip http:// or https:// from import paths before passing to go get\nIMPORT_PATH=\"https://github.com/pkg/errors\"\nIMPORT_PATH=\"${IMPORT_PATH#https://}\"\nIMPORT_PATH=\"${IMPORT_PATH#http://}\"\necho \"$IMPORT_PATH\"  # github.com/pkg/errors\ngo get \"$IMPORT_PATH\"","typeGuard":null,"tryCatchPattern":"# Detect URL-in-import-path error and auto-fix\nERR=$(go get \"$INPUT\" 2>&1)\nif echo \"$ERR\" | grep -q 'not allowed in import path'; then\n  CLEANED=\"${INPUT#https://}\"\n  CLEANED=\"${CLEANED#http://}\"\n  echo \"Stripping scheme — retrying: go get $CLEANED\"\n  go get \"$CLEANED\"\nfi","preventionTips":["Never paste URLs with schemes into go get — use bare import paths","Add a linting check in scripts that strips http(s):// from go get arguments","Train team members on the difference between clone URLs and import paths"],"tags":["vcs","import-path","user-error"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}