github/copilot-sdk · error
no Go package found in
Error message
no Go package found in %q
What it means
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.
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
Example fix
// before: bundler ./assets -> no Go package found in "./assets" // after: bundler ./internal/app (directory with package app)
Defensive patterns
Strategy: validation
Validate before calling
matches, _ := filepath.Glob(filepath.Join(dir, "*.go"))
if len(matches) == 0 {
return fmt.Errorf("%s has no Go files; not a bundle target", dir)
} Try / catch
if err := bundle(dir); err != nil && strings.Contains(err.Error(), "no Go package found") {
// correct the path or build a minimal package first
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- multiple packages and found in
- failed to read package directory
- failed to parse package clause in
- SessionFS.InitialWorkingDirectory is required
- SessionFS.SessionStatePath is required
AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09).
Data as JSON: /api/errors/36fac7506d8dc18b.
Report an issue: GitHub.
Appendix: source
Thrown at go/cmd/bundler/main.go:256
}
path := filepath.Join(dir, name)
file, err := parser.ParseFile(token.NewFileSet(), path, nil, parser.PackageClauseOnly)
if err != nil {
return defaultPackageName, fmt.Errorf("failed to parse package clause in %q: %w", path, err)
}
if packageName == "" {
packageName = file.Name.Name
continue
}
if packageName != file.Name.Name {
return defaultPackageName, fmt.Errorf("multiple packages %q and %q found in %q", packageName, file.Name.Name, dir)
}
}
if packageName == "" {
return defaultPackageName, fmt.Errorf("no Go package found in %q", dir)
}
return packageName, nil
}
// detectCLIVersion detects the CLI version by:
// 1. Running "go list -m" to get the copilot-sdk version from the user's go.mod
// 2. Fetching package.json from the SDK repo at that version
// 3. Extracting the pinned Copilot CLI version from it
func detectCLIVersion() (string, error) {
// Get the SDK version from the user's go.mod
sdkVersion, err := getSDKVersion()
if err != nil {
return "", fmt.Errorf("failed to get SDK version: %w", err)
}
fmt.Printf("Found copilot-sdk %s in go.mod\n", sdkVersion)
// Fetch package.json from the SDK repo at that versionView on GitHub (pinned to cd8cf15dc3)