Standard library / testing/quick

testing/quick.Value()

Generate a reflected value for a supported type; the boolean indicates whether generation succeeded. Struct fields must be exported. Expected stdout: 'uint8 true\n'.

Formal Syntax & Structure

go syntaxgo
func Value(t reflect.Type, rand *rand.Rand) (value reflect.Value, ok bool)

Parameters & Attributes

NameTypeDescription
treflect.TypeRequested reflected type.
rand*rand.RandPseudo-random source for value generation.

Return Value

(value reflect.Value, ok bool)

Result of the operation described above.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/rand"  "reflect"  "testing/quick")
func main() {  v, ok := quick.Value(reflect.TypeOf(uint8(0)), rand.New(rand.NewSource(42)))  fmt.Println(v.Kind(), ok)}
Go Reference