1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-11-25 22:01:39 +02:00

Add rand seed in RAND() (#483) (#484)

This commit is contained in:
Y.Horie
2020-04-28 12:04:38 +09:00
committed by GitHub
parent c9dfb79641
commit 7d7253325e

View File

@@ -3,6 +3,7 @@ package math
import ( import (
"context" "context"
"math/rand" "math/rand"
"time"
"github.com/MontFerret/ferret/pkg/runtime/core" "github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values" "github.com/MontFerret/ferret/pkg/runtime/values"
@@ -20,6 +21,7 @@ func Rand(_ context.Context, args ...core.Value) (core.Value, error) {
} }
if len(args) == 0 { if len(args) == 0 {
rand.Seed(time.Now().UnixNano())
return values.NewFloat(rand.Float64()), nil return values.NewFloat(rand.Float64()), nil
} }