Skip to content

Commit 0106fc7

Browse files
authored
generate: fix error when goimports not found (#50)
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 1cd3965 commit 0106fc7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

generate/generate.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,11 @@ func (e *generateError) Error() string {
123123

124124
type goimportError struct {
125125
output string
126+
error error
126127
}
127128

128129
func (e *goimportError) Error() string {
129-
return fmt.Sprintf("GoImport failed to format:\n%v", e.output)
130+
return fmt.Sprintf("GoImport failed to format:\n%v\n%v", e.output, e.error)
130131
}
131132

132133
type service struct {
@@ -238,7 +239,7 @@ func main() {
238239
}
239240
out, err := exec.Command("goimports", "-w", outdir).CombinedOutput()
240241
if err != nil {
241-
errors = append(errors, &goimportError{string(out)})
242+
errors = append(errors, &goimportError{string(out), err})
242243
}
243244

244245
testdir, err := testDir()
@@ -247,7 +248,7 @@ func main() {
247248
}
248249
out, err = exec.Command("goimports", "-w", testdir).CombinedOutput()
249250
if err != nil {
250-
errors = append(errors, &goimportError{string(out)})
251+
errors = append(errors, &goimportError{string(out), err})
251252
}
252253

253254
if len(errors) > 0 {

0 commit comments

Comments
 (0)