fixing go.mod file - use correct module name and valid Go version. Fixed bug in fibonacci_test.go - test wasn't testing the correct method, it was calling the same one twice

This commit is contained in:
William Dillon 2026-02-26 15:09:45 -05:00
parent 766e407cc3
commit 5d5410000f
4 changed files with 12 additions and 8 deletions

View File

@ -1,7 +1,6 @@
package main
import (
"backoff/fibonacci"
"context"
"flag"
"fmt"
@ -10,6 +9,8 @@ import (
"strconv"
"strings"
"time"
"code.wmdillon.com/wmdillon/backoff/fibonacci"
)
func FormatOutput(pause time.Duration, format string) string {

View File

@ -1,10 +1,11 @@
package fibonacci
import (
"backoff/utilities"
"context"
"fmt"
"time"
"code.wmdillon.com/wmdillon/backoff/utilities"
)
var (
@ -74,13 +75,14 @@ func (f *FibonacciBackoff) Next() time.Duration {
func (f *FibonacciBackoff) After(ctx context.Context) <-chan time.Time {
pause := f.Next()
results := make(chan time.Time, 1)
timer := time.NewTimer(pause)
go func() {
defer close(results)
defer timer.Stop()
select {
case t := <-time.After(pause):
case t := <-timer.C:
results <- t
case <-ctx.Done():
results <- time.Now()
}
}()
return results

View File

@ -1,12 +1,13 @@
package fibonacci
import (
"backoff/utilities"
"context"
"fmt"
"math/big"
"testing"
"time"
"code.wmdillon.com/wmdillon/backoff/utilities"
)
func wouldOverflow(a, b int64) (product int64, overflows bool) {
@ -41,7 +42,7 @@ func TestFibonacciResultsArray(t *testing.T) {
func TestFibonacciFunc(t *testing.T) {
for n := range len(TheFibonacciSequence) {
want := fibonacci(int64(n))
got := fibonacci(int64(n))
got := Fibonacci(int64(n))
if want != got {
t.Fatalf("error for input %d: wanted %d; got %d\n", n, want, got)
}

4
go.mod
View File

@ -1,3 +1,3 @@
module backoff
module code.wmdillon.com/wmdillon/backoff
go 1.25.5
go 1.25