Skip to content

Commit 71a4c29

Browse files
committed
Fix - remove fmt to use log
1 parent 35c335a commit 71a4c29

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

generator/cmd/generator.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package cmd
22

33
import (
44
"errors"
5-
"fmt"
5+
"log"
66
"os"
77
"os/exec"
88
"strings"
@@ -58,7 +58,7 @@ func (g *Generator) getModels(models []string) ([]*model, error) {
5858
return nil, err
5959
}
6060
if len(mfs) == 0 {
61-
fmt.Printf("error: cannot find fields for model %s, cannot generate it.\n", model)
61+
log.Printf("error: cannot find fields for model %s, cannot generate it.\n", model)
6262
continue
6363
}
6464
idExists := false
@@ -68,8 +68,8 @@ func (g *Generator) getModels(models []string) ([]*model, error) {
6868
break
6969
}
7070
}
71-
if idExists == false {
72-
fmt.Printf("error: cannot find ID field for model %s, cannot generate it.\n", model)
71+
if !idExists {
72+
log.Printf("error: cannot find ID field for model %s, cannot generate it.\n", model)
7373
continue
7474
}
7575
mm = append(mm, newModel(model, mfs))
@@ -123,7 +123,7 @@ func (g *Generator) generateModels(models []*model) error {
123123
return err
124124
}
125125
}
126-
fmt.Printf("%s has been generated\n", filePath)
126+
log.Printf("%s has been generated\n", filePath)
127127
}
128128
return nil
129129
}

generator/cmd/root.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package cmd
22

33
import (
4-
"fmt"
5-
"os"
4+
"log"
65
"strings"
76
"text/template"
87

@@ -85,6 +84,5 @@ func initTemplate() {
8584
}
8685

8786
func handleError(err error) {
88-
fmt.Println(err)
89-
os.Exit(1)
87+
log.Fatal(err)
9088
}

0 commit comments

Comments
 (0)