Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix generator tool: ExecuteGoGenerate func #23286

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 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,22 @@ 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 {
fmt.Println(strings.Join(newLines, "\n"))
Alancere marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Errorf("failed to execute `go generate`:\n%s", strings.Join(newLines, "\n"))
}

return nil
}

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