-
Notifications
You must be signed in to change notification settings - Fork 244
Update FlexValue type #129
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
Conversation
linebot/flex.go
Outdated
| type FlexValueType *int | ||
|
|
||
| // FlexValue is helper function for using FlexValueType values | ||
| func FlexValue(v int) FlexValueType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the function name better be FlexInt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I renamed it.
k2wanko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gave a little comment. 👀
|
Fixed tests 🙇 |
|
@sugyan Could you please describe why we should have this? Referencing My suggestion is just letting: And no need: |
|
@linxGnu Good suggestion. |
|
@k2wanko I think so. I believe user has upgrade to go 1.9 for huge improvement at GC and runtime. So I do not think we need to support go1.7 and 1.8. |
|
@sugyan I think you may misunderstand my comment. type FlexValueType *intYou should not do that. Because you are making reference to an int type FlexValueType = intYes, it does not change anything! |
|
I updated my branch again. How about this? |
linebot/flex.go
Outdated
| type FlexValueType = int // alias type | ||
|
|
||
| // FlexInt is a helper function for using *FlexValueType values | ||
| func FlexInt(v int) *FlexValueType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FlexInt is not necessary when using type alias.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm.., how pass 0 as value?
https://github.com/line/line-bot-sdk-go/pull/129/files#diff-40bd644208f7397ac51144bbe03b721bR387
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think *FlexValueType is not necessary. I wonder why we have to embedded the * (reference) instead of value 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you read #124 ?
flex is an optional field and tagged as omitempty, but it should accept the value 0 as not the default value.
So I thought that we have to embed the * (reference) instead of value to omit this field only if the reference is null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 @sugyan Sound reasonable to me. Thank you very much for explanation.
I'm sorry. It is necessary for assembling the structure.
linxGnu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
It looks good in this case. I think that using |
|
Thanks for your comment. |
mokejp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks.
Fix #124.
this is breaking change
For enable to pass
0as value, changed the type offlexfield frominttoFlexValueType(equals to*int), so developers need to change values toFlexValueType. So I added a helper functionFlexInt()to createFlexValueTypevalue.