Skip to content

Commit

Permalink
fix generator tool: ExecuteGoGenerate func (#23286)
Browse files Browse the repository at this point in the history
* fix generator tool

* use a var store err msg
  • Loading branch information
Alancere authored Aug 6, 2024
1 parent e16f3d7 commit a368082
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions eng/tools/generator/cmd/v2/common/cmdProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,23 @@ func ExecuteGoGenerate(path string) error {

if err != nil || stderrBuffer.Len() > 0 {
if stderrBuffer.Len() > 0 {
fmt.Println(stderrBuffer.String())
return fmt.Errorf("failed to execute `go generate`:\n%s", stderrBuffer.String())
// filter go downloading log
// https://github.com/golang/go/blob/1f0c044d60211e435dc58844127544dd3ecb6a41/src/cmd/go/internal/modfetch/fetch.go#L201
lines := strings.Split(stderrBuffer.String(), "\n")
newLines := make([]string, 0, len(lines))
for _, line := range lines {
if !strings.HasPrefix(strings.TrimSpace(line), "go: downloading") {
newLines = append(newLines, line)
}
}

if len(newLines) > 0 {
newErrMsg := strings.Join(newLines, "\n")
fmt.Println(newErrMsg)
return fmt.Errorf("failed to execute `go generate`:\n%s", newErrMsg)
}

return nil
}

return fmt.Errorf("failed to execute `go generate`:\n%+v", err)
Expand Down

0 comments on commit a368082

Please sign in to comment.