+6
-3
cmd/json2go/main.go
+6
-3
cmd/json2go/main.go
···
24
24
25
25
stat, err := os.Stdin.Stat()
26
26
if err != nil {
27
-
panic(err)
27
+
fmt.Printf("Failed to get stdin stat: %v\n", err)
28
+
os.Exit(1)
28
29
}
29
30
30
31
isPiped := (stat.Mode() & os.ModeCharDevice) == 0
···
36
37
case isPiped:
37
38
data, rerr := io.ReadAll(os.Stdin)
38
39
if rerr != nil {
39
-
panic(rerr)
40
+
fmt.Printf("Failed to read piped input: %v\n", rerr)
41
+
os.Exit(1)
40
42
}
41
43
input = string(data)
42
44
default:
···
47
49
transformer := json2go.NewTransformer()
48
50
type_, err := transformer.Transform(*typeName, input)
49
51
if err != nil {
50
-
panic(err)
52
+
fmt.Printf("Failed to transform json to type annotation: %v\n", err)
53
+
os.Exit(1)
51
54
}
52
55
53
56
fmt.Println(type_)