fatih/gomodifytags

Document option to tag all structs

eduhenke opened this issue · 1 comments

I had to search in the issues to see a way for all structs to be used in the file, almost not using this lib(which is great, by the way! only missing a few tiny things, that may hinder the usability). Which I've found the solution to be, to pass line 1,100000.

As for the behavior I expected when I used the gomodifytags command, it would be:

  • gomodifytags -file <file>.go: parses entire file, modify all structs, because no filter option passed
  • gomodifytags -file <file>.go -struct/-line/-offset: gets the entire file, apply the filter, only modify structs that were filtered

But, I don't know if that's everyone's expected behavior, so to at least cover this use case, we could at least document this hidden option, or implement it the proper way(without the line workaround, at least not to the end-user)

fatih commented

Thanks for the feedback @eduhenke You're right. gomodifytags is intended to be used with an editor, hence it never had options to modify the whole file. But I think it's a legit use case. A user could say "Add tags to all structs in the current file". The editor has the knowledge already (file length in numbers), but a command line user doesn't know it.

I've opened a Pull request thats adds the new -all flag which selects all structs: #61 Please use it and let me know what you think about it.