1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-04 10:35:08 +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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ package math
import (
"context"
"math/rand"
"time"
"github.com/MontFerret/ferret/pkg/runtime/core"
"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 {
rand.Seed(time.Now().UnixNano())
return values.NewFloat(rand.Float64()), nil
}