Closed 2opremio closed 8 years ago
ffjson uses comments to control behaviour. go-codec doesn't as a matter of design principle. For that reason, using comments will have a very high barrier for consideration/acceptance.
I would be willing to do a not-match flag i.e. only include types which "match" the "match" regex and "do not match" the "not-match" regex.
I understand the limitations of the golang regex package: however, we will live with it, as that is not the core of the go-codec solution.
Your options are:
Both of these are workable solutions. They are not ideal, but I think (from the POV of the design of go-codec) that using comments is a non-starter. Using comments here will be a one-off solution that feels foreign to the solution - like it was tacked on.
I find the -nr
approach very inconvenient. It requires book-keeping type-names, which is particularly bad if you are not using go generate
since it involves handling type-names outside of sourcecode. But ... your project your rules :). At least it's better than breaking the files in two.
Closing in favor of #140
This is inspired by
// ffjson: skip
There are situations in which the user needs/wants to provide custom
Selfer
s for some of the types declared in a file while still being able to automatically generateSelfer
s for the the rest of the types in that file.For instance see https://github.com/weaveworks/scope/commit/23ddc1b6dd9a3f8ad3f3efa77beaaffa89a68d30
I couldn't find an acceptable way to do this with the existing implementation:
-r
parameter ofcodecgen
is not good enough for excluding types. Regexps are not well suited for negative matching of words. On top of that, Go's regexp implementation intentionally doesn't support lookaheads to comply with its O(n) matching promises, which makes it particularly hard (see http://stackoverflow.com/questions/2078915/a-regular-expression-to-exclude-a-word-string and https://groups.google.com/d/msg/golang-nuts/7qgSDWPIh_E/OHTAm4wRZL0J )