Skip to content

Commit e5ddbc0

Browse files
author
Micro Liu
committed
chore: add fmt cmd for outputs
1 parent f84dd79 commit e5ddbc0

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

cmd/llpyg/llpyg.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ func main() {
6363
// tidy go module
6464
goModTidy(args.OutputDir)
6565

66+
// format go code
67+
codeFormat(args.OutputDir)
68+
6669
fmt.Printf("LLGo bindings generated successfully in %s\n", args.OutputDir)
6770
}
6871

cmd/llpyg/utils.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,15 @@ func goModTidy(outDir string) error {
6565
return nil
6666
}
6767

68+
func codeFormat(outDir string) error {
69+
if err := os.Chdir(outDir); err != nil {
70+
return fmt.Errorf("error: failed to change directory: %w", err)
71+
}
72+
cmd := exec.Command("go", "fmt", "./...")
73+
cmd.Stdout = os.Stdout
74+
cmd.Stderr = os.Stderr
75+
if err := cmd.Run(); err != nil {
76+
return fmt.Errorf("error: failed to format Go code: %w", err)
77+
}
78+
return nil
79+
}

0 commit comments

Comments
 (0)