package main
import "fmt"
import "math/rand"
func main() {
var milesdriven float64
var enginerunningloud bool = true
var changeoil bool = true
if milesdriven >= 3000.0 || enginerunningloud == false {
float64 := (milesdriven * Rand)
changeoil = true
fmt.Println("Change that oil duuuuuude")
}
}
这是我到目前为止所得到的,但我一直在导入而不使用" math / rand"还有一个未定义的兰德是什么意思?我该怎么办?
答案 0 :(得分:2)
有关如何生成随机数的信息,请参阅math/rand
package documentation。 e.g:
package main
import "math/rand"
import "time"
func main() {
seed := time.Now().UnixNano()
random := rand.New(rand.NewSource(seed))
println(random.Float64()) // => +8.277637e-001
println(random.Int()) // => 7112143871403206581
// etc.
}