goadesign / goa

🌟 Goa: Elevate Go API development! 🚀 Streamlined design, automatic code generation, and seamless HTTP/gRPC support. ✨
https://goa.design
MIT License
5.54k stars 556 forks source link

Allow disabling version string in code generated header #3509

Closed davideme closed 2 months ago

davideme commented 3 months ago

When Updating goa version it's hard to detect the files that are only changing the version number and the ones that are changing code.

Screenshot 2024-04-16 at 17 45 42

I'm proposing adding a Meta Field "goa:version:disable" that would disable the version for this specific section.

    Meta("goa:version:disable", "true")

Remarks:

davideme commented 3 months ago

@raphael all suggestions applied. Happy to see it's not far off what was expected.

davideme commented 3 months ago

Any update ?

raphael commented 3 months ago

Sorry for the delay, changes look great! Just one last question: I see a number of places where nil is given as argument for the metadata. This means that these files will still have the version number in the header, is that what we want?

davideme commented 3 months ago

@tchssk I update the Meta name. @raphael I review all the calls to Header,

raphael commented 3 months ago

The changes look great, thank you for the contribution!

tchssk commented 2 months ago

Could you please wait a moment? I'm worried about backward compatibility.

davideme commented 2 months ago

@tchssk let me know which kind of scenario you are thinking? Having the meta tag in a previous version of goa?

davideme commented 2 months ago

Before merging, we are doing some additional testing in our own codebase of around 600 goa generated files.

tchssk commented 2 months ago

Adding arguments to codegen.Header() breaks compatibility. Normally this function is only used internally in Goa, but I'm wondering if there is another way to solve the problem if possible.

raphael commented 2 months ago

Adding arguments to codegen.Header() breaks compatibility. Normally this function is only used internally in Goa, but I'm wondering if there is another way to solve the problem if possible.

  • Adding a cli flag
  • Implement as a plugin

Good point! A third option could be to make the extra parameter optional (e.g. using the functional options pattern). We've avoided adding CLI flags in the past and I'm not sure this would be worth the trade-off.

tchssk commented 2 months ago

I prefer plugins to keep the core simple, but optional parameters aren't bad either.

davideme commented 2 months ago

After testing extensively in our code base, using Meta tag seems impractical. it will fill the design files with tag for each kind of files. I'll explore the plugin way.

tchssk commented 2 months ago

I created a plugin. Here you are. https://github.com/tchssk/goaplugins/tree/master/goaversionremover