Open dsnet opened 2 months ago
One advantage of this is that it makes Null
at the same level of visibility as Bool
, Int
, etc.
In godoc, variables are given less prominence than functions (e.g., variables never show up in the table of contents, while functions do).
I think it is fine. We did the same thing for "constant" values in go-kit/log/level.
https://github.com/go-kit/log/blob/0b69c7049332e99c25d5fd0f4d08317cfe45e7d8/level/level.go#L204-L239
SGTM with the assumption the compiler is/will be clever enough to handle this efficiently
I prefer the old scheme. If it's for immutability, can we set these enums to const string and expose the rawToken helper function?
WARNING: This commit includes breaking changes.
Instead of global variables, use function constructors for static tokens such as Null, ObjectStart, ObjectEnd, ArrayStart, and ArrayEnd. This provides a greater degree of immutability for the API.
Note that static tokens for True and False are dropped in favor of the pre-existing Bool constructor. If necessary, we can always re-introduce True and False.