Skip to content

fix(faker): Keep range generators correct across their whole input domain - #104

Merged
mhiro2 merged 2 commits into
mainfrom
fix/faker-ranges-and-fmt-check
Oct 14, 2026
Merged

mhiro2 merged 2 commits into
mainfrom
fix/faker-ranges-and-fmt-check

Conversation

@mhiro2

@mhiro2 mhiro2 commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • IntBetween, FloatBetween, and DateBetween no longer panic or return infinity for very wide ranges, while ranges that already worked draw the same values for the same seed
  • FloatBetween now panics on reversed, NaN, or infinite bounds like the other range helpers
  • make fmt-check fails when the formatter itself exits non-zero, not only when it prints a diff

Changes

  • 1102608 : fix(faker): keep range generators correct across their whole input domain
    • IntBetween computes its span in uint64, so ranges such as [0, math.MaxInt] and [math.MinInt, math.MaxInt] work
    • DateBetween draws seconds plus nanoseconds when the range exceeds time.Duration (about 292 years), keeping the location of from
    • FloatBetween interpolates between the bounds when max-min overflows and keeps results inside [min, max)
  • be13ae1 : build: fail fmt-check when the formatter exits non-zero
    • The three fmt-check targets share one recipe that checks the exit status and names the module that failed

…main

IntBetween computed max-min+1 in int, so a range such as [0,
math.MaxInt] overflowed and panicked inside IntN; DateBetween relied on
time.Duration, which saturates past about 292 years, so a 1700-2100
range panicked; and FloatBetween returned +Inf when max-min exceeded
math.MaxFloat64. The span is now computed in uint64 for ints, long date
ranges are drawn as seconds plus nanoseconds, and wide float ranges
interpolate between the bounds. Ranges that already worked draw the
same values as before. FloatBetween now states its contract and panics
on reversed, NaN, or infinite bounds like the other range helpers.
The fmt-check targets judged success only by whether the formatter
printed anything, so a formatter that failed silently, as with
GOLANGCI_LINT=false, passed the check. The three targets now share one
recipe that also fails on a non-zero exit status and reports which
module failed.
@github-actions

Copy link
Copy Markdown

Code Metrics Report

main (9a2b1f6) #104 (db13c19) +/-
Coverage 86.9% 86.9% +0.0%
Code to Test Ratio 1:1.0 1:1.0 +0.0
Test Execution Time 1m11s 1m21s +10s
Details
  |                     | main (9a2b1f6) | #104 (db13c19) |  +/-  |
  |---------------------|----------------|----------------|-------|
+ | Coverage            |          86.9% |          86.9% | +0.0% |
  |   Files             |             59 |             59 |     0 |
  |   Lines             |           4791 |           4813 |   +22 |
+ |   Covered           |           4165 |           4186 |   +21 |
+ | Code to Test Ratio  |          1:1.0 |          1:1.0 |  +0.0 |
  |   Code              |          17787 |          17821 |   +34 |
+ |   Test              |          17916 |          17988 |   +72 |
- | Test Execution Time |          1m11s |          1m21s |  +10s |

Code coverage of files in pull request scope (98.8% → 98.1%, patch 97.2%)

Files Coverage +/- Patch Coverage Status
faker/faker.go 98.1% -0.7% 97.2% modified

Reported by octocov

@mhiro2 mhiro2 self-assigned this Oct 14, 2026
@mhiro2 mhiro2 added the bug Something isn't working label Oct 14, 2026
@mhiro2
mhiro2 merged commit 8524941 into main Oct 14, 2026
11 checks passed
@mhiro2
mhiro2 deleted the fix/faker-ranges-and-fmt-check branch October 14, 2026 13:03
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 this pull request may close these issues.

1 participant