(goCmd string, inputPath string, outputPath string, importName string, forceRegenerate bool, resetFields bool)
| 24 | ) |
| 25 | |
| 26 | func GenerateFiles(goCmd string, inputPath string, outputPath string, importName string, forceRegenerate bool, resetFields bool) error { |
| 27 | |
| 28 | if _, StatErr := os.Stat(outputPath); !os.IsNotExist(StatErr) { |
| 29 | inputFileInfo, inputFileErr := os.Stat(inputPath) |
| 30 | outputFileInfo, outputFileErr := os.Stat(outputPath) |
| 31 | |
| 32 | if nil == outputFileErr && nil == inputFileErr { |
| 33 | if !forceRegenerate && inputFileInfo.ModTime().Before(outputFileInfo.ModTime()) { |
| 34 | fmt.Println("File " + outputPath + " already exists.") |
| 35 | |
| 36 | return nil |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | packageName, structs, err := ExtractStructs(inputPath) |
| 42 | if err != nil { |
| 43 | return err |
| 44 | } |
| 45 | |
| 46 | im := NewInceptionMain(goCmd, inputPath, outputPath, resetFields) |
| 47 | |
| 48 | err = im.Generate(packageName, structs, importName) |
| 49 | if err != nil { |
| 50 | return errors.New(fmt.Sprintf("error=%v path=%q", err, im.TempMainPath)) |
| 51 | } |
| 52 | |
| 53 | err = im.Run() |
| 54 | if err != nil { |
| 55 | return err |
| 56 | } |
| 57 | |
| 58 | return nil |
| 59 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…