{"record":{"id":"36fac7506d8dc18b","repo":"github/copilot-sdk","slug":"no-go-package-found-in-q","errorCode":null,"errorMessage":"no Go package found in %q","messagePattern":"no Go package found in %q","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/cmd/bundler/main.go","lineNumber":256,"sourceCode":"\t\t}\n\n\t\tpath := filepath.Join(dir, name)\n\t\tfile, err := parser.ParseFile(token.NewFileSet(), path, nil, parser.PackageClauseOnly)\n\t\tif err != nil {\n\t\t\treturn defaultPackageName, fmt.Errorf(\"failed to parse package clause in %q: %w\", path, err)\n\t\t}\n\n\t\tif packageName == \"\" {\n\t\t\tpackageName = file.Name.Name\n\t\t\tcontinue\n\t\t}\n\t\tif packageName != file.Name.Name {\n\t\t\treturn defaultPackageName, fmt.Errorf(\"multiple packages %q and %q found in %q\", packageName, file.Name.Name, dir)\n\t\t}\n\t}\n\n\tif packageName == \"\" {\n\t\treturn defaultPackageName, fmt.Errorf(\"no Go package found in %q\", dir)\n\t}\n\treturn packageName, nil\n}\n\n// detectCLIVersion detects the CLI version by:\n// 1. Running \"go list -m\" to get the copilot-sdk version from the user's go.mod\n// 2. Fetching package.json from the SDK repo at that version\n// 3. Extracting the pinned Copilot CLI version from it\nfunc detectCLIVersion() (string, error) {\n\t// Get the SDK version from the user's go.mod\n\tsdkVersion, err := getSDKVersion()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get SDK version: %w\", err)\n\t}\n\n\tfmt.Printf(\"Found copilot-sdk %s in go.mod\\n\", sdkVersion)\n\n\t// Fetch package.json from the SDK repo at that version","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/cmd/bundler/main.go#L238-L274","documentation":"If the directory walk finishes without any successfully parsed package clause, detectPackageName cannot determine a package name and returns this error with the defaultPackageName fallback. It means no parseable Go package exists in the target directory.","triggerScenarios":"The directory passed to the bundler contains no .go files at all, or every .go file failed to parse earlier in the loop (leaving packageName empty at the end).","commonSituations":"Pointing the bundler at the wrong path (e.g. an assets or docs directory); an empty freshly created package directory; all sources hidden by the walk's skip rules.","solutions":["Verify the directory path contains at least one valid .go file","Run ls <dir>/*.go to confirm Go sources exist and are non-empty","Fix any parse errors reported in earlier files so detection can succeed","Re-run the bundler from the correct package directory"],"exampleFix":"// before: bundler ./assets -> no Go package found in \"./assets\"\n// after: bundler ./internal/app  (directory with package app)","handlingStrategy":"validation","validationCode":"matches, _ := filepath.Glob(filepath.Join(dir, \"*.go\"))\nif len(matches) == 0 {\n    return fmt.Errorf(\"%s has no Go files; not a bundle target\", dir)\n}","typeGuard":null,"tryCatchPattern":"if err := bundle(dir); err != nil && strings.Contains(err.Error(), \"no Go package found\") {\n    // correct the path or build a minimal package first\n}","preventionTips":["Confirm the target directory contains *.go files before bundling","Run `go list ./...` to validate package paths","Use paths relative to the module root to avoid pointing at asset dirs"],"tags":["go","bundling","packages","directory"],"backgroundTag":"directory-not-found","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}