MCPcopy Create free account
hub / github.com/apache/fory / Run

Function Run

go/fory/codegen/generator.go:45–71  ·  view source on GitHub ↗

Run executes the code generator with the given options

(opts *GeneratorOptions)

Source from the content-addressed store, hash-verified

43
44// Run executes the code generator with the given options
45func Run(opts *GeneratorOptions) error {
46 // If force flag is set, clean up existing files first
47 if opts.Force {
48 logger.Printf("Force flag detected, cleaning up existing generated files...")
49 if cleanupErr := cleanupGeneratedFiles(opts); cleanupErr != nil {
50 logger.Printf("Warning: Failed to cleanup generated files: %v", cleanupErr)
51 }
52 }
53
54 err := run(opts)
55
56 // Check if the error is due to compile-time guard conflicts
57 if err != nil && isCompileGuardError(err.Error()) {
58 logger.Printf("Detected compile-time guard conflict. Attempting to regenerate...")
59
60 // Try to clean up and regenerate
61 if cleanupErr := cleanupGeneratedFiles(opts); cleanupErr != nil {
62 logger.Printf("Warning: Failed to cleanup generated files: %v", cleanupErr)
63 }
64
65 // Retry generation
66 logger.Printf("Retrying code generation...")
67 return run(opts)
68 }
69
70 return err
71}
72
73func run(opts *GeneratorOptions) error {
74 // Determine mode: file-based or package-based

Callers

nothing calls this directly

Calls 4

cleanupGeneratedFilesFunction · 0.85
runFunction · 0.70
isCompileGuardErrorFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected