Skip to content
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

[BUG] v2.0.3 returns incorrect values for Int and UInt methods #164

Closed
trentclowater opened this issue Jan 21, 2024 · 6 comments · Fixed by #167
Closed

[BUG] v2.0.3 returns incorrect values for Int and UInt methods #164

trentclowater opened this issue Jan 21, 2024 · 6 comments · Fixed by #167
Labels
bug Something isn't working

Comments

@trentclowater
Copy link

Describe the bug
Changes made to v2.0.3 seem to have broken the Int and Uint methods. The sample code in the Go Playground will generate the output below (10 random numbers for each method). Only Uint() appears to be working correctly.

Int64: [-9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808]
Int32: [0 0 0 0 0 0 0 0 0 0]
Int16: [0 0 0 0 0 0 0 0 0 0]
Int8: [0 0 0 0 0 0 0 0 0 0]
Int: [-9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808]

UInt64: [9223372036854775808 9223372036854775808 9223372036854775808 9223372036854775808 9223372036854775808 9223372036854775808 9223372036854775808 9223372036854775808 9223372036854775808 9223372036854775808]
UInt32: [0 0 0 0 0 0 0 0 0 0]
UInt16: [0 0 0 0 0 0 0 0 0 0]
UInt8: [0 0 0 0 0 0 0 0 0 0]
UInt: [7656741239857252927 5594207809226113391 6008768823903029407 2021276371439549788 338472662231586328 7331582930402992456 1862095825495157913 6678231846753265959 9208902309648365007 549713215453345498]

They appear to be working more correctly with v2.0.2 (although Int64 and Int do not appear to be producing any negative values with v2.0.2):

Int64: [4457966027044790232 3068793850071510156 4241597960427124847 7097929654138723183 53203214098893531 4549093053679149128 4180637979454261572 7573092381611586563 9173485451690427125 3851087538435533936]
Int32: [-455826018 -1258706307 -1044868518 851197946 -1216443716 515121644 1535424041 -1623242824 -434048819 -921841709]
Int16: [-4581 17178 24303 15499 16902 12949 9880 14951 11319 -6594]
Int8: [-122 100 72 -102 -22 15 -88 -5 110 120]
Int: [7533801517110527743 6978115144997277611 6286691177520792259 4024021042162847838 5061842129050809232 4191043012286955853 3602606074011605235 6839266255701396663 4091504718573783711 4638797404464528346]

UInt64: [41055368818041555 8938590738929278265 1192535113924107347 1668087444309155861 4833168004950273266 790332503801125400 3813344926054000253 1394808423049600791 7440181255669925228 7712871825341992071]
UInt32: [3719961827 1904474432 1215507601 2700000476 1190456603 2950735355 3292251569 3440930050 1848275514 1027039561]
UInt16: [61836 3570 34601 53919 3204 10354 64422 49933 10516 41437]
UInt8: [197 130 112 80 117 215 25 130 68 70]
UInt: [122291367368253944 9184109984619104570 6913572135790214506 4359817097239585374 7179945772768069149 228053568771661241 180971267124051659 832342306344858062 2357607085026279658 1566666409152456504]

To Reproduce
See https://goplay.tools/snippet/6eRhDKSKzfW

Expected behavior
A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

  • OS: Mac OS 14.1.1 (Sonoma)
  • go version output: go version go1.21.6 darwin/arm64
@trentclowater trentclowater added the bug Something isn't working label Jan 21, 2024
@jaswdr
Copy link
Owner

jaswdr commented Jan 22, 2024

@trentclowater thank you for reporting, I'll check this out.

@stephenafamo
Copy link

Did you find some time to take a look at this @jaswdr

@edigaryev
Copy link

This seems to be already fixed by #165, unfortunately, it's not tagged/released yet.

A quick workaround is to:

go get -u github.com/jaswdr/faker/v2@ae23891d4c901b3603aad44fa0bba41cf0735f84

@trentclowater
Copy link
Author

@edigaryev Note that #165 just reverts a fix for a panic that existed originally, so the potential for a panic is still there. The problems with Int64 and Int only returning positive numbers still exists also. So even though it is no longer returning 0 values, it still has some problems.

@jaswdr
Copy link
Owner

jaswdr commented Feb 16, 2024

@stephenafamo unfortunately I was not able to got to this.

#165 is not released in any version yet because I was still testing it, although in the end we should revert it and re-apply the fix to mitigate the panic. The side effect is that previously the numbers where mostly between 0..100 and now they are much bigger, although this is not a bug I understand that it could break people's code. Fortunately there are many other methods that people can use instead, so my actions items are:

  1. Revert Revert "fix intn panic (#163)" #165 and fix the issue.
  2. Release it as minor version update instead of bug-fix (1.X)
  3. Refer in the release notes to use RandomNumber or IntBetween instead of just Int

@jaswdr
Copy link
Owner

jaswdr commented Feb 18, 2024

Released v2.1.0 with fix and tests to avoid this issue. Please @trentclowater check it out and feel free to reopen this issue if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants