New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve default value handling for primitive types #287
Comments
This was a helpful blog entry, which break down the issues and presents some solutions. Optional JSON Fields in Go.
I vote for 1 using pointers as the design choice, with a policy that it is only introduced for fields with known non-nil defaults. [Otherwise, it might become cumbersome for maintainer and user.] |
I am pushing a simple implementation of (1) above with my PR #285 ... I was wondering where to document this, and I won't make documentation part of that PR.. Is it OK to put in a section in the README? Or just in the GoDoc? |
I just tried this out and here's what my dependent code saw:
It was very easy to go to that line and update it
|
Hi @neomantra , thanks a lot for your input on it !
I agree that the And about those Besides, If we gonna make it in a brand new Go big or go home. |
I saw the The great thing about the change is that it is not silent and it is easy to fix. Are there massive Here's a ported example from my codebase, to help think about it:
I think that we do need Like you say, I think the approach of documenting this feature generally and then explicitly using it for fields that need it. If it's a |
Yep, the most important thing in front of me is how we should handle the
To handle the
Agree. TBH, I know that we are lack of docs for now and then. 😅 Actually, it was a plan to get a doc site to clarify options and examples but it is always delay. |
I haven't looked recently, but I did appreciate the new code organization of
I can take a stab at this, but also didn't want to duplicate work with you or anybody. I would do what we described... go through the options, find ones that have non-zero defaults, and add the wrapper type to those. |
Hi @neomantra , sorry that I'm more into the |
OK, feel free to assign this to me (I don't have permissions to do so). Not sure on timing, but I'll stab at it. But if you are pushing on FYI, another feature I'm background-working on is Custom charts. I have it working, but not in a way I love. I should just throw out a WIP PR. Or is that being addressed with your |
Assign to you now, take your time is fine. 👌
I think it may have a WIP pr drop here, although it based on v2 . we could take a look on it and think about how to integrate it into v3 as well. About the v3, it just starts up and I m quite dizzy about how to achieve those apis. 😅 |
As discussed #285, there are issues with the marshaling / unmarshalling of the defaults of basic types, when the default is not
nil
. Capturing it here as an issue.There are a few ways of handling it, such as using pointers or custom types.
The text was updated successfully, but these errors were encountered: