@@ -348,7 +348,7 @@ func (cmd *Cmd) RewriteTargets(ctx context.Context, targets []string) error {
348
348
}
349
349
350
350
if err := rewrite (ctx , cfg ); err != nil {
351
- log . ExitContext ( ctx , err )
351
+ return err
352
352
}
353
353
354
354
return nil
@@ -534,13 +534,33 @@ func rewrite(ctx context.Context, cfg *config) (err error) {
534
534
fmt .Fprintf (os .Stderr , "Can't fix builds: %v\n " , err )
535
535
}
536
536
}
537
+ fmt .Println ()
537
538
if fail > 0 {
538
- return fmt .Errorf ("%d packages could not be rewritten" , fail )
539
+ return fmt .Errorf (rewriteFailedFmt , fail )
539
540
}
540
541
541
542
return nil
542
543
}
543
544
545
+ const rewriteFailedFmt = `%d packages could not be rewritten
546
+
547
+ Frequent mistakes include:
548
+
549
+ - Enabling the Opaque API before rewriting your code.
550
+ Instead, set your .proto files to the Hybrid API
551
+ before running open2opaque rewrite. For details, see
552
+ https://protobuf.dev/reference/go/opaque-migration/
553
+
554
+ - Your code must build for the open2opaque tool to work.
555
+ Check that a build shows no errors: go build ./...
556
+
557
+ - Incorrectly migrating .proto files to edition 2023.
558
+ It is not sufficient to only replace the syntax line.
559
+ To preserve your current behavior (proto2 or proto3)
560
+ when migrating to edition 2023, follow this document:
561
+ https://protobuf.dev/editions/features/#preserving
562
+ `
563
+
544
564
func runGoimports (dir string , files []string ) error {
545
565
fmt .Printf ("\t Running goimports on %d files\n " , len (files ))
546
566
// Limit concurrent processes.
0 commit comments