Browse Source

supporting Go1

drhodes 13 năm trước cách đây
mục cha
commit
75c66cd673
1 tập tin đã thay đổi với 2 bổ sung3 xóa
  1. 2 3
      lorem.go

+ 2 - 3
lorem.go

@@ -5,17 +5,16 @@
 package lorem
 package lorem
 
 
 import (
 import (
-	"rand"
+	"math/rand"
 	"time"
 	"time"
 	"strings"
 	"strings"
 )
 )
 
 
-var src = rand.New(rand.NewSource(time.Nanoseconds()))
+var src = rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
 
 
 // Generate a natural word len.
 // Generate a natural word len.
 func genWordLen() int {
 func genWordLen() int {
 	f := src.Float32() * 100
 	f := src.Float32() * 100
-
 	// a table of word lengths and their frequencies.
 	// a table of word lengths and their frequencies.
 	switch {
 	switch {
 	case f < 1.939:
 	case f < 1.939: