(appId string, fileName string)
| 407 | } |
| 408 | |
| 409 | func FormatGoFile(appId string, fileName string) error { |
| 410 | if err := ValidateAppId(appId); err != nil { |
| 411 | return fmt.Errorf("invalid appId: %w", err) |
| 412 | } |
| 413 | |
| 414 | appDir, err := GetAppDir(appId) |
| 415 | if err != nil { |
| 416 | return err |
| 417 | } |
| 418 | |
| 419 | filePath, err := validateAndResolveFilePath(appDir, fileName) |
| 420 | if err != nil { |
| 421 | return err |
| 422 | } |
| 423 | |
| 424 | if filepath.Ext(filePath) != ".go" { |
| 425 | return fmt.Errorf("file is not a Go file: %s", fileName) |
| 426 | } |
| 427 | |
| 428 | gofmtPath, err := waveapputil.ResolveGoFmtPath() |
| 429 | if err != nil { |
| 430 | return fmt.Errorf("failed to resolve gofmt path: %w", err) |
| 431 | } |
| 432 | |
| 433 | cmd := exec.Command(gofmtPath, "-w", filePath) |
| 434 | if output, err := cmd.CombinedOutput(); err != nil { |
| 435 | return fmt.Errorf("gofmt failed: %w\nOutput: %s", err, string(output)) |
| 436 | } |
| 437 | |
| 438 | return nil |
| 439 | } |
| 440 | |
| 441 | func ListAllAppFiles(appId string) (*fileutil.ReadDirResult, error) { |
| 442 | if err := ValidateAppId(appId); err != nil { |
no test coverage detected