wavetermdev/waveterm · error
file is not a Go file: %s
Error message
file is not a Go file: %s
What it means
FormatGoFile only formats Go source; after resolving the file path inside the app directory it checks filepath.Ext(filePath) == ".go". If the requested file has any other extension, it returns "file is not a Go file" with the original fileName. This guards gofmt from being run on non-Go files.
Source
Thrown at pkg/waveappstore/waveappstore.go:425
}
func FormatGoFile(appId string, fileName string) error {
if err := ValidateAppId(appId); err != nil {
return fmt.Errorf("invalid appId: %w", err)
}
appDir, err := GetAppDir(appId)
if err != nil {
return err
}
filePath, err := validateAndResolveFilePath(appDir, fileName)
if err != nil {
return err
}
if filepath.Ext(filePath) != ".go" {
return fmt.Errorf("file is not a Go file: %s", fileName)
}
gofmtPath, err := waveapputil.ResolveGoFmtPath()
if err != nil {
return fmt.Errorf("failed to resolve gofmt path: %w", err)
}
cmd := exec.Command(gofmtPath, "-w", filePath)
if output, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("gofmt failed: %w\nOutput: %s", err, string(output))
}
return nil
}
func ListAllAppFiles(appId string) (*fileutil.ReadDirResult, error) {
if err := ValidateAppId(appId); err != nil {
return nil, fmt.Errorf("invalid appId: %w", err)View on GitHub (pinned to a4447c1563)
Solutions
- Only call FormatGoFile for files ending in ".go"; route other file types to their own formatters (prettier, etc.)
- Check strings.HasSuffix(fileName, ".go") in the caller before invoking
- If the file genuinely is Go source, rename it to have a .go extension first (RenameAppFile)
- Handle the error gracefully in UI by disabling the format action for non-Go files
Example fix
// before
FormatGoFile(appId, fileName)
// after
if strings.HasSuffix(fileName, ".go") {
FormatGoFile(appId, fileName)
} Defensive patterns
Strategy: validation
Validate before calling
if !strings.HasSuffix(fileName, ".go") {
return fmt.Errorf("%s is not a Go file; use the appropriate formatter", fileName)
} Type guard
func isGoFile(name string) bool { return strings.HasSuffix(strings.ToLower(name), ".go") } Try / catch
if err := FormatGoFile(appId, fileName); err != nil {
if strings.Contains(err.Error(), "file is not a Go file") {
return nil // skip formatting for non-Go files
}
return err
} Prevention
- Route format requests to formatters by file extension (.go -> gofmt, .ts/.tsx -> prettier, etc.)
- Check the extension before enabling the format action in UI
- Remember the check is extension-based: a Go file must end in .go to be formattable
When it happens
Trigger: Calling FormatGoFile on e.g. "manifest.json", "index.tsx", "style.css", or any file without a ".go" extension within the app directory.
Common situations: A generic "format this file" frontend action routed to the Go formatter regardless of file type; user opens a README and hits format; case-sensitivity issue where the file is named "MAIN.GO" — actually .GO uppercase also fails since Ext comparison is case-sensitive on Linux.
Related errors
- Image too large (>5MB)
- Unsupported or invalid image type: ${blob.type}
- Invalid CSS color: ${String(color)}
- Invalid CSS color: ${color}
- ai:model is required
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/5fa35397796c21af.
Report an issue: GitHub.